Documentation ¶
Index ¶
- Constants
- func CacheConfiguration() (err error)
- func GetLocalAddress() (string, error)
- func GetLocalIP() string
- func GetPeerEndpoint() (*pb.PeerEndpoint, error)
- func NewPeerClientConnection() (*grpc.ClientConn, error)
- func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error)
- func SecurityEnabled() bool
- func SyncBlocksChannelSize() int
- func SyncStateDeltasChannelSize() int
- func SyncStateSnapshotChannelSize() int
- func ValidatorEnabled() bool
- type BlockChainAccessor
- type BlockChainModifier
- type BlockChainUtil
- type BlocksRetriever
- type ChatStream
- type Discoverer
- type DiscoveryAccessor
- type DiscoveryPersistor
- type DuplicateHandlerError
- type Engine
- type EngineFactory
- type Handler
- func (d *Handler) HandleMessage(msg *pb.Message) error
- func (d *Handler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
- func (d *Handler) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
- func (d *Handler) RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
- func (d *Handler) SendMessage(msg *pb.Message) error
- func (d *Handler) Stop() error
- func (d *Handler) To() (pb.PeerEndpoint, error)
- type HandlerFactory
- type Impl
- func (p *Impl) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
- func (p *Impl) Broadcast(msg *pb.Message, typ pb.PeerEndpoint_Type) []error
- func (p *Impl) Chat(stream pb.Peer_ChatServer) error
- func (p *Impl) CommitStateDelta(id interface{}) error
- func (p *Impl) DeregisterHandler(messageHandler MessageHandler) error
- func (p *Impl) EmptyState() error
- func (p *Impl) ExecuteTransaction(transaction *pb.Transaction) (response *pb.Response)
- func (p *Impl) GetBlockByNumber(blockNumber uint64) (*pb.Block, error)
- func (p *Impl) GetBlockchainSize() uint64
- func (p *Impl) GetCurrentStateHash() (stateHash []byte, err error)
- func (p *Impl) GetDiscHelper() discovery.Discovery
- func (p *Impl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
- func (p *Impl) GetPeers() (*pb.PeersMessage, error)
- func (p *Impl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error)
- func (p *Impl) GetSecHelper() crypto.Peer
- func (p *Impl) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
- func (p *Impl) GetStateSnapshot() (*state.StateSnapshot, error)
- func (p *Impl) HashBlock(block *pb.Block) ([]byte, error)
- func (p *Impl) Load(key string) ([]byte, error)
- func (p *Impl) LoadDiscoveryList() ([]string, error)
- func (p *Impl) NewOpenchainDiscoveryHello() (*pb.Message, error)
- func (p *Impl) PeersDiscovered(peersMessage *pb.PeersMessage) error
- func (p *Impl) ProcessTransaction(ctx context.Context, tx *pb.Transaction) (response *pb.Response, err error)
- func (p *Impl) PutBlock(blockNumber uint64, block *pb.Block) error
- func (p *Impl) RegisterHandler(messageHandler MessageHandler) error
- func (p *Impl) RollbackStateDelta(id interface{}) error
- func (p *Impl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)
- func (p *Impl) Store(key string, value []byte) error
- func (p *Impl) StoreDiscoveryList() error
- func (p *Impl) Unicast(msg *pb.Message, receiverHandle *pb.PeerID) error
- func (p *Impl) VerifyBlockchain(start, finish uint64) (uint64, error)
- type MessageHandler
- type MessageHandlerCoordinator
- type Peer
- type Persistor
- type RemoteLedger
- type SecurityAccessor
- type StateAccessor
- type StateRetriever
- type TransactionProccesor
Constants ¶
const DefaultSyncSnapshotTimeout time.Duration = 60 * time.Second
Variables ¶
This section is empty.
Functions ¶
func CacheConfiguration ¶
func CacheConfiguration() (err error)
CacheConfiguration computes and caches commonly-used constants and computed constants as package variables. Routines which were previously global have been embedded here to preserve the original abstraction.
func GetLocalAddress ¶
GetLocalAddress returns the peer.address property
func GetPeerEndpoint ¶
func GetPeerEndpoint() (*pb.PeerEndpoint, error)
GetPeerEndpoint returns peerEndpoint from cached configuration
func NewPeerClientConnection ¶
func NewPeerClientConnection() (*grpc.ClientConn, error)
NewPeerClientConnection Returns a new grpc.ClientConn to the configured local PEER.
func NewPeerClientConnectionWithAddress ¶
func NewPeerClientConnectionWithAddress(peerAddress string) (*grpc.ClientConn, error)
NewPeerClientConnectionWithAddress Returns a new grpc.ClientConn to the configured local PEER.
func SecurityEnabled ¶
func SecurityEnabled() bool
SecurityEnabled returns the securityEnabled property from cached configuration
func SyncBlocksChannelSize ¶
func SyncBlocksChannelSize() int
SyncBlocksChannelSize returns the peer.sync.blocks.channelSize property
func SyncStateDeltasChannelSize ¶
func SyncStateDeltasChannelSize() int
SyncStateDeltasChannelSize returns the peer.sync.state.deltas.channelSize property
func SyncStateSnapshotChannelSize ¶
func SyncStateSnapshotChannelSize() int
SyncStateSnapshotChannelSize returns the peer.sync.state.snapshot.channelSize property
func ValidatorEnabled ¶
func ValidatorEnabled() bool
ValidatorEnabled returns the peer.validator.enabled property
Types ¶
type BlockChainAccessor ¶
type BlockChainAccessor interface { GetBlockByNumber(blockNumber uint64) (*pb.Block, error) GetBlockchainSize() uint64 GetCurrentStateHash() (stateHash []byte, err error) }
BlockChainAccessor interface for retreiving blocks by block number
type BlockChainModifier ¶
type BlockChainModifier interface { ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error RollbackStateDelta(id interface{}) error CommitStateDelta(id interface{}) error EmptyState() error PutBlock(blockNumber uint64, block *pb.Block) error }
BlockChainModifier interface for applying changes to the block chain
type BlockChainUtil ¶
type BlockChainUtil interface { HashBlock(block *pb.Block) ([]byte, error) VerifyBlockchain(start, finish uint64) (uint64, error) }
BlockChainUtil interface for interrogating the block chain
type BlocksRetriever ¶
type BlocksRetriever interface {
RequestBlocks(*pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
}
BlocksRetriever interface for retrieving blocks .
type ChatStream ¶
ChatStream interface supported by stream between Peers
type Discoverer ¶
type Discoverer interface { DiscoveryAccessor DiscoveryPersistor }
Discoverer enables a peer to access/persist/restore its discovery list
type DiscoveryAccessor ¶
DiscoveryAccessor enables a peer to hand out its discovery object
type DiscoveryPersistor ¶
type DiscoveryPersistor interface { LoadDiscoveryList() ([]string, error) StoreDiscoveryList() error }
DiscoveryPersistor enables a peer to persist/restore its discovery list to/from the database
type DuplicateHandlerError ¶
type DuplicateHandlerError struct {
To pb.PeerEndpoint
}
DuplicateHandlerError returned if attempt to register same chaincodeID while a stream already exists.
func (*DuplicateHandlerError) Error ¶
func (d *DuplicateHandlerError) Error() string
type Engine ¶
type Engine interface { TransactionProccesor // GetHandlerFactory return a handler for an accepted Chat stream GetHandlerFactory() HandlerFactory }
Engine Responsible for managing Peer network communications (Handlers) and processing of Transactions
type EngineFactory ¶
type EngineFactory func(MessageHandlerCoordinator) (Engine, error)
EngineFactory for creating new engines
type Handler ¶
type Handler struct { ToPeerEndpoint *pb.PeerEndpoint Coordinator MessageHandlerCoordinator ChatStream ChatStream FSM *fsm.FSM // contains filtered or unexported fields }
Handler peer handler implementation.
func (*Handler) HandleMessage ¶
HandleMessage handles the Openchain messages for the Peer.
func (*Handler) RequestBlocks ¶
func (d *Handler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
RequestBlocks get the blocks from the other PeerEndpoint based upon supplied SyncBlockRange, will provide them through the returned channel. this will also stop writing any received blocks to channels created from Prior calls to RequestBlocks(..)
func (*Handler) RequestStateDeltas ¶
func (d *Handler) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
RequestStateDeltas get the state snapshot deltas from the other PeerEndpoint, will provide them through the returned channel. this will also stop writing any received syncStateSnapshot(s) to channels created from Prior calls to GetStateSnapshot()
func (*Handler) RequestStateSnapshot ¶
func (d *Handler) RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
RequestStateSnapshot request the state snapshot deltas from the other PeerEndpoint, will provide them through the returned channel. this will also stop writing any received syncStateSnapshot(s) to channels created from Prior calls to RequestStateSnapshot()
func (*Handler) SendMessage ¶
SendMessage sends a message to the remote PEER through the stream
type HandlerFactory ¶
type HandlerFactory func(MessageHandlerCoordinator, ChatStream, bool) (MessageHandler, error)
HandlerFactory for creating new MessageHandlers
type Impl ¶
type Impl struct {
// contains filtered or unexported fields
}
Impl implementation of the Peer service
func NewPeerWithEngine ¶
func NewPeerWithEngine(secHelperFunc func() crypto.Peer, engFactory EngineFactory) (peer *Impl, err error)
NewPeerWithEngine returns a Peer which uses the supplied handler factory function for creating new handlers on new Chat service invocations.
func NewPeerWithHandler ¶
func NewPeerWithHandler(secHelperFunc func() crypto.Peer, handlerFact HandlerFactory) (*Impl, error)
NewPeerWithHandler returns a Peer which uses the supplied handler factory function for creating new handlers on new Chat service invocations.
func (*Impl) ApplyStateDelta ¶
func (p *Impl) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
ApplyStateDelta applies a state delta to the current state The result of this function can be retrieved using GetCurrentStateDelta To commit the result, call CommitStateDelta, or to roll it back call RollbackStateDelta
func (*Impl) Broadcast ¶
Broadcast broadcast a message to each of the currently registered PeerEndpoints of given type Broadcast will broadcast to all registered PeerEndpoints if the type is PeerEndpoint_UNDEFINED
func (*Impl) Chat ¶
func (p *Impl) Chat(stream pb.Peer_ChatServer) error
Chat implementation of the the Chat bidi streaming RPC function
func (*Impl) CommitStateDelta ¶
CommitStateDelta makes the result of ApplyStateDelta permanent and releases the resources necessary to rollback the delta
func (*Impl) DeregisterHandler ¶
func (p *Impl) DeregisterHandler(messageHandler MessageHandler) error
DeregisterHandler deregisters an already registered MessageHandler for this coordinator
func (*Impl) EmptyState ¶
EmptyState completely empties the state and prepares it to restore a snapshot
func (*Impl) ExecuteTransaction ¶
func (p *Impl) ExecuteTransaction(transaction *pb.Transaction) (response *pb.Response)
ExecuteTransaction executes transactions decides to do execute in dev or prod mode
func (*Impl) GetBlockByNumber ¶
GetBlockByNumber return a block by block number
func (*Impl) GetBlockchainSize ¶
GetBlockchainSize returns the height/length of the blockchain
func (*Impl) GetCurrentStateHash ¶
GetCurrentStateHash returns the current non-committed hash of the in memory state
func (*Impl) GetDiscHelper ¶
GetDiscHelper enables a peer to retrieve its discovery object
func (*Impl) GetPeerEndpoint ¶
func (p *Impl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
GetPeerEndpoint returns the endpoint for this peer
func (*Impl) GetPeers ¶
func (p *Impl) GetPeers() (*pb.PeersMessage, error)
GetPeers returns the currently registered PeerEndpoints
func (*Impl) GetRemoteLedger ¶
func (p *Impl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error)
GetRemoteLedger returns the RemoteLedger interface for the remote Peer Endpoint
func (*Impl) GetSecHelper ¶
GetSecHelper returns the crypto.Peer
func (*Impl) GetStateDelta ¶
func (p *Impl) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
GetStateDelta return the state delta for the requested block number
func (*Impl) GetStateSnapshot ¶
func (p *Impl) GetStateSnapshot() (*state.StateSnapshot, error)
GetStateSnapshot return the state snapshot
func (*Impl) Load ¶
Load enables a peer to read the value that corresponds to the given database key
func (*Impl) LoadDiscoveryList ¶
LoadDiscoveryList enables a peer to load the discovery list from the database
func (*Impl) NewOpenchainDiscoveryHello ¶
NewOpenchainDiscoveryHello constructs a new HelloMessage for sending
func (*Impl) PeersDiscovered ¶
func (p *Impl) PeersDiscovered(peersMessage *pb.PeersMessage) error
PeersDiscovered used by MessageHandlers for notifying this coordinator of discovered PeerEndoints. May include this Peer's PeerEndpoint.
func (*Impl) ProcessTransaction ¶
func (p *Impl) ProcessTransaction(ctx context.Context, tx *pb.Transaction) (response *pb.Response, err error)
ProcessTransaction implementation of the ProcessTransaction RPC function
func (*Impl) PutBlock ¶
PutBlock inserts a raw block into the blockchain at the specified index, nearly no error checking is performed
func (*Impl) RegisterHandler ¶
func (p *Impl) RegisterHandler(messageHandler MessageHandler) error
RegisterHandler register a MessageHandler with this coordinator
func (*Impl) RollbackStateDelta ¶
RollbackStateDelta undoes the results of ApplyStateDelta to revert the current state back to the state before ApplyStateDelta was invoked
func (*Impl) SendTransactionsToPeer ¶
func (p *Impl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)
SendTransactionsToPeer forwards transactions to the specified peer address.
func (*Impl) StoreDiscoveryList ¶
StoreDiscoveryList enables a peer to persist the discovery list to the database
type MessageHandler ¶
type MessageHandler interface { RemoteLedger HandleMessage(msg *pb.Message) error SendMessage(msg *pb.Message) error To() (pb.PeerEndpoint, error) Stop() error }
MessageHandler standard interface for handling Openchain messages.
func NewPeerHandler ¶
func NewPeerHandler(coord MessageHandlerCoordinator, stream ChatStream, initiatedStream bool) (MessageHandler, error)
NewPeerHandler returns a new Peer handler Is instance of HandlerFactory
type MessageHandlerCoordinator ¶
type MessageHandlerCoordinator interface { Peer SecurityAccessor BlockChainAccessor BlockChainModifier BlockChainUtil StateAccessor RegisterHandler(messageHandler MessageHandler) error DeregisterHandler(messageHandler MessageHandler) error Broadcast(*pb.Message, pb.PeerEndpoint_Type) []error Unicast(*pb.Message, *pb.PeerID) error GetPeers() (*pb.PeersMessage, error) GetRemoteLedger(receiver *pb.PeerID) (RemoteLedger, error) PeersDiscovered(*pb.PeersMessage) error ExecuteTransaction(transaction *pb.Transaction) *pb.Response Discoverer }
MessageHandlerCoordinator responsible for coordinating between the registered MessageHandler's
type Peer ¶
type Peer interface { GetPeerEndpoint() (*pb.PeerEndpoint, error) NewOpenchainDiscoveryHello() (*pb.Message, error) }
Peer provides interface for a peer
type Persistor ¶
Persistor enables a peer to persist and restore data to the database TODO Move over the persist package from consensus down to the peer level
type RemoteLedger ¶
type RemoteLedger interface { BlocksRetriever StateRetriever }
RemoteLedger interface for retrieving remote ledger data.
type SecurityAccessor ¶
SecurityAccessor interface enables a Peer to hand out the crypto object for Peer
type StateAccessor ¶
type StateAccessor interface { GetStateSnapshot() (*state.StateSnapshot, error) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error) }
StateAccessor interface for retreiving blocks by block number
type StateRetriever ¶
type StateRetriever interface { RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error) RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error) }
StateRetriever interface for retrieving state deltas, etc.
type TransactionProccesor ¶
type TransactionProccesor interface {
ProcessTransactionMsg(*pb.Message, *pb.Transaction) *pb.Response
}
TransactionProccesor responsible for processing of Transactions