Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit df422e1

Browse files
committed
FABJ-288 lifecycle
PS 10 Code works end2end needs Fabric commits. 11 Reverse unintended changes. 12 Fix queries 13 Clean up 14 Make class name more consistent. 15 Added namespace query. 16 Cleanup 17 Update for chaincode hash 18 Update to support init on invoke call. 19 Update to latest fabric changes. 20 Remove unneeded setting in peer.yaml 21 Support for QueryApprovalStatus 22 Fix up validation parameter 23 Cleanup 24 Cleanup 25 Cleanup 26 Cleanup 27 Collections fixes. 28 Minor refactor 29 Find sequence number. 30 Parameter checking. 31 Cleanup Parameter checking. 32 Cleanup 33 Cleanup more checks. 34 Javadoc 35 Javadoc deprecated 36 Javadoc updates. 37 Change how sourceNone is specified. 38 Change source None to Unavailable 39 Javadoc updates 40 Add missing protobuf 41 Rebuilt orderer block and v2channel with implicit policies. 42 Remove whitespace 44 Remove reference to Token protos. Change-Id: I324bf96511cc532aa1f0e53d3dc50a4ea445b686 Signed-off-by: rickr <cr22rc@gmail.com>
1 parent ef153c8 commit df422e1

File tree

188 files changed

+7663
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+7663
-190
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ and execute the following commands:
239239
* configtxgen --configPath . -outputCreateChannelTx foo.tx -profile TwoOrgsChannel_v13 -channelID foo
240240
* configtxgen --configPath . -outputCreateChannelTx bar.tx -profile TwoOrgsChannel_v13 -channelID bar
241241

242+
For v2.0 integration, cd to the `src/test/fixture/sdkintegration/e2e-2Orgs/v2.0` directory
243+
* configtxgen --configPath . -outputCreateChannelTx v2channel.tx -profile TwoOrgsChannel_v20 -channelID v2channel
244+
* configtxgen --configPath . -outputBlock orderer.block -profile TwoOrgsOrdererGenesis_v20 -channelID systemOrdererChannel
245+
246+
242247
This should produce the following files in the same directory: orderer.block, foo.tx, and bar.tx
243248

244249
**Note:** The above describes how this was done. If you redo this there are private key files

config.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
#org.hyperledger.fabric.sdk.client.thread_executor_keepalivetime=60
4444
## the time unit for the {@code keepAliveTime} argument (SECONDS,MILLISECONDS,NANOSECDONS) see Java's TimeUnit
4545
#org.hyperledger.fabric.sdk.client.thread_executor_keepalivetimeunit=SECONDS
46+
## The default chaincode endorsement plugin. This should never need setting unless you've changed peer to include another endorser plugin.
47+
#org.hyperledger.fabric.sdk.lifecycle.chaincode_endorsement_plugin
48+
## The default chaincode validation plugin. This should never need setting unless you've changed peer to include another validation plugin.
49+
#org.hyperledger.fabric.sdk.lifecycle.chaincode_validation_plugin
50+
## The default if chaincode will require an init routine. The default is to not set the protobuf which sets to false. / true or false
51+
#org.hyperledger.fabric.sdk.lifecycle.initRequiredDefault=false
4652

4753
# System wide defaults for CryptoPrimitives objects. You can customize further by using the
4854
# CryptoPrimitives.setProperties() method.

src/main/java/org/hyperledger/fabric/sdk/BlockInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ public EnvelopeType getType() {
363363
/**
364364
* Return a specific envelope in the block by it's index.
365365
*
366-
* @param envelopeIndex
367-
* @return EnvelopeInfo that contains information on the envelope.
366+
* @param envelopeIndex the index into list.
367+
* @return envelopeIndex the index
368368
* @throws InvalidProtocolBufferException
369369
*/
370370

src/main/java/org/hyperledger/fabric/sdk/ChaincodeCollectionConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
public class ChaincodeCollectionConfiguration {
5151
private static final Log logger = LogFactory.getLog(ChaincodeCollectionConfiguration.class);
5252
private static final Pattern noofPattern = Pattern.compile("^(\\d+)-of$");
53+
54+
Collection.CollectionConfigPackage getCollectionConfigPackage() {
55+
return collectionConfigPackage;
56+
}
57+
5358
private Collection.CollectionConfigPackage collectionConfigPackage = null;
5459

5560
ChaincodeCollectionConfiguration(JsonArray jsonConfig) throws ChaincodeCollectionConfigurationException {

src/main/java/org/hyperledger/fabric/sdk/ChaincodeEndorsementPolicy.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.FileInputStream;
1919
import java.io.IOException;
2020
import java.io.InputStream;
21+
import java.nio.file.Path;
2122
import java.util.HashMap;
2223
import java.util.LinkedHashMap;
2324
import java.util.List;
@@ -41,6 +42,9 @@
4142
*/
4243
public class ChaincodeEndorsementPolicy {
4344
private static final Pattern noofPattern = Pattern.compile("^(\\d+)-of$");
45+
/**
46+
* Serialized Policies.SignaturePolicyEnvelope protobuf
47+
*/
4448
private byte[] policyBytes = null;
4549

4650
/**
@@ -229,6 +233,7 @@ public void fromFile(File policyFile) throws IOException {
229233
* @param yamlPolicyFile File location for the chaincode endorsement policy specification.
230234
* @throws IOException
231235
* @throws ChaincodeEndorsementPolicyParseException
236+
* @deprecated use {@link #fromYamlFile(Path)}
232237
*/
233238

234239
public void fromYamlFile(File yamlPolicyFile) throws IOException, ChaincodeEndorsementPolicyParseException {
@@ -252,6 +257,31 @@ public void fromYamlFile(File yamlPolicyFile) throws IOException, ChaincodeEndor
252257
.build().toByteArray();
253258
}
254259

260+
public static ChaincodeEndorsementPolicy fromYamlFile(Path yamlPolicyFile) throws IOException, ChaincodeEndorsementPolicyParseException {
261+
final Yaml yaml = new Yaml();
262+
final Map<?, ?> load = (Map<?, ?>) yaml.load(new FileInputStream(yamlPolicyFile.toFile()));
263+
264+
Map<?, ?> mp = (Map<?, ?>) load.get("policy");
265+
266+
if (null == mp) {
267+
throw new ChaincodeEndorsementPolicyParseException("The policy file has no policy section");
268+
}
269+
270+
IndexedHashMap<String, MSPPrincipal> identities = parseIdentities((Map<?, ?>) load.get("identities"));
271+
272+
SignaturePolicy sp = parsePolicy(identities, mp);
273+
274+
ChaincodeEndorsementPolicy chaincodeEndorsementPolicy = new ChaincodeEndorsementPolicy();
275+
276+
chaincodeEndorsementPolicy.policyBytes = Policies.SignaturePolicyEnvelope.newBuilder()
277+
.setVersion(0)
278+
.addAllIdentities(identities.values())
279+
.setRule(sp)
280+
.build().toByteArray();
281+
282+
return chaincodeEndorsementPolicy;
283+
}
284+
255285
/**
256286
* Construct a chaincode endorsement policy from a stream.
257287
*
@@ -268,8 +298,20 @@ public void fromStream(InputStream inputStream) throws IOException {
268298
*
269299
* @param policyAsBytes the byte array containing the serialized policy
270300
*/
271-
public void fromBytes(byte[] policyAsBytes) {
272-
this.policyBytes = policyAsBytes;
301+
public static ChaincodeEndorsementPolicy fromBytes(byte[] policyAsBytes) {
302+
303+
ChaincodeEndorsementPolicy ret = new ChaincodeEndorsementPolicy();
304+
305+
ret.policyBytes = new byte[policyAsBytes.length];
306+
System.arraycopy(policyAsBytes, 0, ret.policyBytes, 0, policyAsBytes.length);
307+
return ret;
308+
}
309+
310+
public byte[] getPolicyBytes() {
311+
312+
byte[] ret = new byte[policyBytes.length];
313+
System.arraycopy(policyBytes, 0, ret, 0, policyBytes.length); // provide a copy.
314+
return ret;
273315
}
274316

275317
/**

src/main/java/org/hyperledger/fabric/sdk/ChaincodeID.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* ChaincodeID identifies chaincode.
19+
* @deprecated See lifecycle install {@link LifecycleChaincodePackage}
1920
*/
2021
public final class ChaincodeID {
2122

@@ -29,6 +30,10 @@ public org.hyperledger.fabric.protos.peer.Chaincode.ChaincodeID getFabricChainco
2930
this.fabricChaincodeID = chaincodeID;
3031
}
3132

33+
/**
34+
* @return
35+
* @deprecated See lifecycle install {@link LifecycleChaincodePackage}
36+
*/
3237
public String getName() {
3338
return fabricChaincodeID.getName();
3439
}
@@ -99,6 +104,7 @@ public ChaincodeID build() {
99104
/**
100105
* Chaincode builder
101106
*
107+
* @deprecated See lifecycle install {@link LifecycleChaincodePackage}
102108
* @return ChaincodeID builder.
103109
*/
104110

0 commit comments

Comments
 (0)