Skip to content

Commit 9fc6da2

Browse files
committed
[FAB-6574] Integrate simpleCollectionStore for gossip
This change sets switches the implementation of the collection store from the No-op collection store to the simple collection store. Change-Id: I38e5e1d8c25ad260eb6077e3aee9ff8f4f9c3664 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent 525d214 commit 9fc6da2

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

core/common/privdata/collection.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,22 @@ type CollectionStore interface {
6464
// GetCollectionAccessPolicy retrieves a collection's access policy
6565
RetrieveCollectionAccessPolicy(common.CollectionCriteria) (CollectionAccessPolicy, error)
6666
}
67+
68+
const (
69+
// Collecion-specific constants
70+
71+
// collectionSeparator is the separator used to build the KVS
72+
// key storing the collections of a chaincode; note that we are
73+
// using as separator a character which is illegal for either the
74+
// name or the version of a chaincode so there cannot be any
75+
// collisions when chosing the name
76+
collectionSeparator = "~"
77+
// collectionSuffix is the suffix of the KVS key storing the
78+
// collections of a chaincode
79+
collectionSuffix = "collection"
80+
)
81+
82+
// BuildCollectionKVSKey returns the KVS key string for a chaincode, given its name and version
83+
func BuildCollectionKVSKey(ccname string) string {
84+
return ccname + collectionSeparator + collectionSuffix
85+
}

core/peer/peer.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
"runtime"
1313
"sync"
1414

15-
"github.com/hyperledger/fabric/core/ledger/customtx"
16-
1715
"github.com/hyperledger/fabric/common/channelconfig"
1816
cc "github.com/hyperledger/fabric/common/config"
1917
"github.com/hyperledger/fabric/common/configtx"
@@ -33,6 +31,7 @@ import (
3331
"github.com/hyperledger/fabric/core/committer/txvalidator"
3432
"github.com/hyperledger/fabric/core/common/privdata"
3533
"github.com/hyperledger/fabric/core/ledger"
34+
"github.com/hyperledger/fabric/core/ledger/customtx"
3635
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
3736
"github.com/hyperledger/fabric/core/transientstore"
3837
"github.com/hyperledger/fabric/gossip/api"
@@ -376,11 +375,14 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
376375
if err != nil {
377376
return errors.Wrapf(err, "Failed opening transient store for %s", bundle.ConfigtxValidator().ChainID())
378377
}
378+
simpleCollectionStore := privdata.NewSimpleCollectionStore(&collectionSupport{
379+
PeerLedger: ledger,
380+
})
379381
service.GetGossipService().InitializeChannel(bundle.ConfigtxValidator().ChainID(), ordererAddresses, service.Support{
380382
Validator: validator,
381383
Committer: c,
382384
Store: store,
383-
Cs: &privdata.NopCollectionStore{},
385+
Cs: simpleCollectionStore,
384386
})
385387

386388
chains.Lock()
@@ -724,6 +726,22 @@ func GetPeerServer() comm.GRPCServer {
724726
return peerServer
725727
}
726728

729+
type collectionSupport struct {
730+
ledger.PeerLedger
731+
}
732+
733+
func (cs *collectionSupport) GetQueryExecutorForLedger(cid string) (ledger.QueryExecutor, error) {
734+
return cs.NewQueryExecutor()
735+
}
736+
737+
func (*collectionSupport) GetCollectionKVSKey(cc common.CollectionCriteria) string {
738+
return privdata.BuildCollectionKVSKey(cc.Namespace)
739+
}
740+
741+
func (*collectionSupport) GetIdentityDeserializer(chainID string) msp.IdentityDeserializer {
742+
return mspmgmt.GetManagerForChain(chainID)
743+
}
744+
727745
//
728746
// Deliver service support structs for the peer
729747
//

0 commit comments

Comments
 (0)