Skip to content

Commit

Permalink
FAB-1018 Gossip multi-channel support API design
Browse files Browse the repository at this point in the history
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 <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Nov 10, 2016
1 parent ac66f24 commit 62e45af
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
10 changes: 2 additions & 8 deletions gossip/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
62 changes: 62 additions & 0 deletions gossip/api/channel.go
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 62e45af

Please sign in to comment.