Skip to content

Commit

Permalink
[FAB-6574] Integrate simpleCollectionStore for gossip
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yacovm committed Dec 19, 2017
1 parent 525d214 commit 9fc6da2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
19 changes: 19 additions & 0 deletions core/common/privdata/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,22 @@ type CollectionStore interface {
// GetCollectionAccessPolicy retrieves a collection's access policy
RetrieveCollectionAccessPolicy(common.CollectionCriteria) (CollectionAccessPolicy, error)
}

const (
// Collecion-specific constants

// collectionSeparator is the separator used to build the KVS
// key storing the collections of a chaincode; note that we are
// using as separator a character which is illegal for either the
// name or the version of a chaincode so there cannot be any
// collisions when chosing the name
collectionSeparator = "~"
// collectionSuffix is the suffix of the KVS key storing the
// collections of a chaincode
collectionSuffix = "collection"
)

// BuildCollectionKVSKey returns the KVS key string for a chaincode, given its name and version
func BuildCollectionKVSKey(ccname string) string {
return ccname + collectionSeparator + collectionSuffix
}
24 changes: 21 additions & 3 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"runtime"
"sync"

"github.com/hyperledger/fabric/core/ledger/customtx"

"github.com/hyperledger/fabric/common/channelconfig"
cc "github.com/hyperledger/fabric/common/config"
"github.com/hyperledger/fabric/common/configtx"
Expand All @@ -33,6 +31,7 @@ import (
"github.com/hyperledger/fabric/core/committer/txvalidator"
"github.com/hyperledger/fabric/core/common/privdata"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/customtx"
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
"github.com/hyperledger/fabric/core/transientstore"
"github.com/hyperledger/fabric/gossip/api"
Expand Down Expand Up @@ -376,11 +375,14 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
if err != nil {
return errors.Wrapf(err, "Failed opening transient store for %s", bundle.ConfigtxValidator().ChainID())
}
simpleCollectionStore := privdata.NewSimpleCollectionStore(&collectionSupport{
PeerLedger: ledger,
})
service.GetGossipService().InitializeChannel(bundle.ConfigtxValidator().ChainID(), ordererAddresses, service.Support{
Validator: validator,
Committer: c,
Store: store,
Cs: &privdata.NopCollectionStore{},
Cs: simpleCollectionStore,
})

chains.Lock()
Expand Down Expand Up @@ -724,6 +726,22 @@ func GetPeerServer() comm.GRPCServer {
return peerServer
}

type collectionSupport struct {
ledger.PeerLedger
}

func (cs *collectionSupport) GetQueryExecutorForLedger(cid string) (ledger.QueryExecutor, error) {
return cs.NewQueryExecutor()
}

func (*collectionSupport) GetCollectionKVSKey(cc common.CollectionCriteria) string {
return privdata.BuildCollectionKVSKey(cc.Namespace)
}

func (*collectionSupport) GetIdentityDeserializer(chainID string) msp.IdentityDeserializer {
return mspmgmt.GetManagerForChain(chainID)
}

//
// Deliver service support structs for the peer
//
Expand Down

0 comments on commit 9fc6da2

Please sign in to comment.