Skip to content

Commit 9b7d402

Browse files
committed
[FAB-5863] Collection-related APIs
This commit defines 2 APIs: - An API that declares the needed methods that the coordinator would invoke on gossip, in gossip/api/subchannel.go - An API that the coordinator would use to fetch policies for sub-channels, in core/common/privdata/policies.go Change-Id: I6e7b7176e2c3b29e069b998214c6aaddd0a37008 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent 6925648 commit 9b7d402

File tree

5 files changed

+143
-29
lines changed

5 files changed

+143
-29
lines changed

core/common/privdata/policies.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package privdata
8+
9+
import "github.com/hyperledger/fabric/protos/ledger/rwset"
10+
11+
// SerializedPolicy defines a persisted policy
12+
type SerializedPolicy interface {
13+
// Channel returns the channel this SerializedPolicy corresponds to
14+
Channel() string
15+
// Raw returns the policy in its raw form
16+
Raw() []byte
17+
}
18+
19+
// SerializedIdentity defines an identity of a network participant
20+
type SerializedIdentity []byte
21+
22+
// PolicyStore defines an object that retrieves stored SerializedPolicies
23+
// based on the collection's properties
24+
type PolicyStore interface {
25+
// GetPolicy retrieves the collection policy from in the following way:
26+
// If the TxID exists in the ledger, the policy that is returned is the latest policy
27+
// which was committed into the ledger before this txID was committed.
28+
// Else - it's the latest policy for the collection.
29+
CollectionPolicy(rwset.CollectionCriteria) SerializedPolicy
30+
}
31+
32+
// Filter defines a rule that filters out SerializedIdentities
33+
// that the policy doesn't hold for them.
34+
// Returns: True, if the policy holds for the given SerializedIdentity,
35+
// False otherwise
36+
type Filter func(SerializedIdentity) bool
37+
38+
// PolicyParser parses SerializedPolicies and returns a Filter
39+
type PolicyParser interface {
40+
// Parse parses a given SerializedPolicy and returns a Filter
41+
// that is derived from it
42+
Parse(SerializedPolicy) Filter
43+
}

gossip/api/subchannel.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package api
8+
9+
import "github.com/hyperledger/fabric/gossip/common"
10+
11+
// RoutingFilter defines which peers should receive a certain message,
12+
// or which peers are eligible of receiving a certain message
13+
type RoutingFilter func(peerIdentity PeerIdentityType) bool
14+
15+
// CollectionCriteria describes a certain sub-channel, or a part of it
16+
type CollectionCriteria []byte
17+
18+
// RoutingFilterFactory defines an object that given a CollectionCriteria and a channel,
19+
// it can ascertain which peers should be aware of the data related to the
20+
// CollectionCriteria.
21+
type RoutingFilterFactory interface {
22+
// Peers returns a RoutingFilter for given chainID and CollectionCriteria
23+
Peers(common.ChainID, CollectionCriteria) RoutingFilter
24+
}

protos/gossip/message.pb.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/ledger/rwset/rwset.pb.go

Lines changed: 65 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/ledger/rwset/rwset.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,12 @@ message NsPvtReadWriteSet {
6262
message CollectionPvtReadWriteSet {
6363
string collection_name = 1;
6464
bytes rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
65+
}
66+
67+
// CollectionProperty defines an element of a private data that corresponds
68+
// to a certain transaction and collection
69+
message CollectionCriteria {
70+
string channel = 1;
71+
string tx_id = 2;
72+
string collection = 3;
6573
}

0 commit comments

Comments
 (0)