diff --git a/gossip/api/api.go b/gossip/api/api.go index 226f3c61442..477289ed01b 100644 --- a/gossip/api/api.go +++ b/gossip/api/api.go @@ -16,18 +16,12 @@ limitations under the License. package api - // GossipService is used to publish new blocks to the gossip network type GossipService interface { // payload: Holds the block's content, hash and seqNum Publish(payload Payload) error } -type BindAddress struct { - Host string - Port int16 -} - // Payload defines an object that contains a ledger block type Payload struct { Data []byte // The content of the message, possibly encrypted or signed @@ -54,12 +48,12 @@ type ReplicationProvider interface { LastBlockSeq() uint64 } -// MessageCryptoVerifier verifies the message's authenticity, +// MessageCryptoService verifies the message's authenticity, // if messages are cryptographically signed type MessageCryptoService interface { // Verify returns nil whether the message and its identifier are authentic, // otherwise returns an error - VerifyBlock(seqNum uint64, pkiId []byte, payload Payload) error + VerifyBlock(seqNum uint64, pkiID []byte, payload Payload) error // Sign signs msg with this peer's signing key and outputs // the signature if no error occurred. diff --git a/gossip/api/channel.go b/gossip/api/channel.go new file mode 100644 index 00000000000..e19ee78127e --- /dev/null +++ b/gossip/api/channel.go @@ -0,0 +1,62 @@ +/* +Copyright IBM Corp. 2016 All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package api + +import "time" + +// SecurityAdvisor defines an external auxiliary object +// that provides security and identity related capabilities +type SecurityAdvisor interface { + // IsInMyOrg returns whether the given peer's certificate represents + // a peer in the invoker's organization + IsInMyOrg(PeerCert) bool + + // Verify verifies a JoinChannelMessage, returns nil on success, + // and an error on failure + Verify(JoinChannelMessage) error +} + +// ChannelNotifier is implemented by the gossip component and is used for the peer +// layer to notify the gossip component of a JoinChannel event +type ChannelNotifier interface { + JoinChannel(joinMsg JoinChannelMessage, chainID ChainID) +} + +// JoinChannelMessage is the message that asserts a creation or mutation +// of a channel's membership list, and is the message that is gossipped +// among the peers +type JoinChannelMessage interface { + + // GetTimestamp returns the timestamp of the message's creation + GetTimestamp() time.Time + + // PeerList returns all the peers that are in the channel + PeerList() []RemotePeer +} + +// ChainID defines the identity representation of a chain +type ChainID []byte + +// RemotePeer is a peer's certificate and endpoint (host:port) +type RemotePeer struct { + cert PeerCert + host string + port int +} + +// PeerCert defines the cryptographic identity of a peer +type PeerCert []byte