Skip to content

Commit 62e45af

Browse files
committed
FAB-1018 Gossip multi-channel support API design
https://jira.hyperledger.org/browse/FAB-1018 This commit contains code that should be implemented by layers that use the gossip component. This code enables the gossip component to determine to which peers it may forward a certain block according to the channel Change-Id: I01d274ef91837b5d5b4e8bc0d78a49df90957185 Signed-off-by: Yacov Manevich <[email protected]>
1 parent ac66f24 commit 62e45af

File tree

2 files changed

+64
-8
lines changed

2 files changed

+64
-8
lines changed

gossip/api/api.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ limitations under the License.
1616

1717
package api
1818

19-
2019
// GossipService is used to publish new blocks to the gossip network
2120
type GossipService interface {
2221
// payload: Holds the block's content, hash and seqNum
2322
Publish(payload Payload) error
2423
}
2524

26-
type BindAddress struct {
27-
Host string
28-
Port int16
29-
}
30-
3125
// Payload defines an object that contains a ledger block
3226
type Payload struct {
3327
Data []byte // The content of the message, possibly encrypted or signed
@@ -54,12 +48,12 @@ type ReplicationProvider interface {
5448
LastBlockSeq() uint64
5549
}
5650

57-
// MessageCryptoVerifier verifies the message's authenticity,
51+
// MessageCryptoService verifies the message's authenticity,
5852
// if messages are cryptographically signed
5953
type MessageCryptoService interface {
6054
// Verify returns nil whether the message and its identifier are authentic,
6155
// otherwise returns an error
62-
VerifyBlock(seqNum uint64, pkiId []byte, payload Payload) error
56+
VerifyBlock(seqNum uint64, pkiID []byte, payload Payload) error
6357

6458
// Sign signs msg with this peer's signing key and outputs
6559
// the signature if no error occurred.

gossip/api/channel.go

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright IBM Corp. 2016 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package api
18+
19+
import "time"
20+
21+
// SecurityAdvisor defines an external auxiliary object
22+
// that provides security and identity related capabilities
23+
type SecurityAdvisor interface {
24+
// IsInMyOrg returns whether the given peer's certificate represents
25+
// a peer in the invoker's organization
26+
IsInMyOrg(PeerCert) bool
27+
28+
// Verify verifies a JoinChannelMessage, returns nil on success,
29+
// and an error on failure
30+
Verify(JoinChannelMessage) error
31+
}
32+
33+
// ChannelNotifier is implemented by the gossip component and is used for the peer
34+
// layer to notify the gossip component of a JoinChannel event
35+
type ChannelNotifier interface {
36+
JoinChannel(joinMsg JoinChannelMessage, chainID ChainID)
37+
}
38+
39+
// JoinChannelMessage is the message that asserts a creation or mutation
40+
// of a channel's membership list, and is the message that is gossipped
41+
// among the peers
42+
type JoinChannelMessage interface {
43+
44+
// GetTimestamp returns the timestamp of the message's creation
45+
GetTimestamp() time.Time
46+
47+
// PeerList returns all the peers that are in the channel
48+
PeerList() []RemotePeer
49+
}
50+
51+
// ChainID defines the identity representation of a chain
52+
type ChainID []byte
53+
54+
// RemotePeer is a peer's certificate and endpoint (host:port)
55+
type RemotePeer struct {
56+
cert PeerCert
57+
host string
58+
port int
59+
}
60+
61+
// PeerCert defines the cryptographic identity of a peer
62+
type PeerCert []byte

0 commit comments

Comments
 (0)