Skip to content

Commit

Permalink
Merge "[FAB-5863] Collection-related APIs"
Browse files Browse the repository at this point in the history
  • Loading branch information
denyeart authored and Gerrit Code Review committed Aug 23, 2017
2 parents 1f591ab + 9b7d402 commit decef7c
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 29 deletions.
43 changes: 43 additions & 0 deletions core/common/privdata/policies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package privdata

import "github.com/hyperledger/fabric/protos/ledger/rwset"

// SerializedPolicy defines a persisted policy
type SerializedPolicy interface {
// Channel returns the channel this SerializedPolicy corresponds to
Channel() string
// Raw returns the policy in its raw form
Raw() []byte
}

// SerializedIdentity defines an identity of a network participant
type SerializedIdentity []byte

// PolicyStore defines an object that retrieves stored SerializedPolicies
// based on the collection's properties
type PolicyStore interface {
// GetPolicy retrieves the collection policy from in the following way:
// If the TxID exists in the ledger, the policy that is returned is the latest policy
// which was committed into the ledger before this txID was committed.
// Else - it's the latest policy for the collection.
CollectionPolicy(rwset.CollectionCriteria) SerializedPolicy
}

// Filter defines a rule that filters out SerializedIdentities
// that the policy doesn't hold for them.
// Returns: True, if the policy holds for the given SerializedIdentity,
// False otherwise
type Filter func(SerializedIdentity) bool

// PolicyParser parses SerializedPolicies and returns a Filter
type PolicyParser interface {
// Parse parses a given SerializedPolicy and returns a Filter
// that is derived from it
Parse(SerializedPolicy) Filter
}
24 changes: 24 additions & 0 deletions gossip/api/subchannel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package api

import "github.com/hyperledger/fabric/gossip/common"

// RoutingFilter defines which peers should receive a certain message,
// or which peers are eligible of receiving a certain message
type RoutingFilter func(peerIdentity PeerIdentityType) bool

// CollectionCriteria describes a certain sub-channel, or a part of it
type CollectionCriteria []byte

// RoutingFilterFactory defines an object that given a CollectionCriteria and a channel,
// it can ascertain which peers should be aware of the data related to the
// CollectionCriteria.
type RoutingFilterFactory interface {
// Peers returns a RoutingFilter for given chainID and CollectionCriteria
Peers(common.ChainID, CollectionCriteria) RoutingFilter
}
4 changes: 3 additions & 1 deletion protos/gossip/message.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 65 additions & 28 deletions protos/ledger/rwset/rwset.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions protos/ledger/rwset/rwset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ message NsPvtReadWriteSet {
message CollectionPvtReadWriteSet {
string collection_name = 1;
bytes rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
}

// CollectionProperty defines an element of a private data that corresponds
// to a certain transaction and collection
message CollectionCriteria {
string channel = 1;
string tx_id = 2;
string collection = 3;
}

0 comments on commit decef7c

Please sign in to comment.