private Protos.Common.CollectionConfigPackage Parse(JArray jsonConfig) { Protos.Common.CollectionConfigPackage ls = new Protos.Common.CollectionConfigPackage(); foreach (JToken j in jsonConfig) { JObject scf = j["StaticCollectionConfig"] as JObject; if (scf == null) { throw new ChaincodeCollectionConfigurationException($"Expected StaticCollectionConfig to be Object type but got: {j.Type.ToString()}"); } StaticCollectionConfig ssc = new StaticCollectionConfig(); ssc.Name = scf["name"].Value <string>(); ssc.BlockToLive = scf["blockToLive"].Value <ulong>(); ssc.MaximumPeerCount = scf["maximumPeerCount"].Value <int>(); CollectionPolicyConfig cpc = new CollectionPolicyConfig(); cpc.SignaturePolicy = ParseSignaturePolicyEnvelope(scf); ssc.MemberOrgsPolicy = cpc; ssc.RequiredPeerCount = scf["requiredPeerCount"].Value <int>(); Protos.Common.CollectionConfig cf = new Protos.Common.CollectionConfig(); cf.StaticCollectionConfig = ssc; ls.Config.Add(cf); } return(ls); }
public ChaincodeCollectionConfiguration(JArray jsonConfig) { collectionConfigPackage = Parse(jsonConfig); if (collectionConfigPackage == null) { throw new ChaincodeCollectionConfigurationException("Parsing collection configuration produce null configuration."); } }
/* * public void setCollectionConfigPackage(Collection.CollectionConfigPackage collectionConfigPackage) { * this.collectionConfigPackage = collectionConfigPackage; * } */ public static ChaincodeCollectionConfiguration FromCollectionConfigPackage(Protos.Common.CollectionConfigPackage collectionConfigPackage) { // Sanity check if (collectionConfigPackage == null) { throw new ArgumentException("collectionConfigPackage must be specified"); } return(new ChaincodeCollectionConfiguration(collectionConfigPackage)); }
public ChaincodeCollectionConfiguration(Protos.Common.CollectionConfigPackage collectionConfigPackage) { this.collectionConfigPackage = collectionConfigPackage; }