Repository navigation
Add ParseCollectionConfig helper to build CollectionConfigPackage from a JSON string - #252
Open
Ishaan-Gpt wants to merge 1 commit into
Open
Ishaan-Gpt wants to merge 1 commit into
Ishaan-Gpt wants to merge 1 commit into
Conversation
Defining private data collections currently requires building the peer.CollectionConfigPackage structure by hand, which is cumbersome and error prone. This adds a ParseCollectionConfig function in pkg/chaincode that accepts a collection configuration string in the same JSON format as the Fabric peer CLI collections configuration file and converts it into a peer.CollectionConfigPackage ready for ChaincodeDefinition.Collections. Member orgs policies reuse the existing signature policy parsing, and the required and maximum peer counts fall back to 0 and 1 when omitted, the same defaults the Fabric peer CLI uses. An optional endorsement policy can be given as a signature policy string or a channel config policy reference. Signed-off-by: Ishaan-Gpt <ishaangupta011205@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defining private data collections with the SDK currently requires building peer.CollectionConfigPackage by hand, which is cumbersome and error prone. This adds a ParseCollectionConfig function in pkg/chaincode that takes a collection configuration string in the same JSON format as the Fabric peer CLI collections configuration file, and converts it into a peer.CollectionConfigPackage ready for ChaincodeDefinition.Collections.
Member orgs policies reuse the existing signature policy parsing, so policy strings like OR('Org1MSP.member', 'Org2MSP.member') work as expected. Required and max peer counts default to 0 and 1 when omitted, matching the Fabric peer CLI behavior. An optional endorsement policy can be given as a signature policy string or a channel config policy reference.
Tests: new unit tests in pkg/chaincode/collectionconfig_test.go cover a full config, multiple collections, peer count defaults, an endorsement policy, invalid JSON, and an invalid policy. go build, go vet and go test on the chaincode package all pass locally.
Fixes #199.