Documentation ¶
Index ¶
- 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 MessageHandler
- type MessageHandlerCoordinator
- type Peer
- type PeerImpl
- func (p *PeerImpl) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
- func (p *PeerImpl) Broadcast(msg *pb.Message, typ pb.PeerEndpoint_Type) []error
- func (p *PeerImpl) Chat(stream pb.Peer_ChatServer) error
- func (p *PeerImpl) CommitStateDelta(id interface{}) error
- func (p *PeerImpl) DeregisterHandler(messageHandler MessageHandler) error
- func (p *PeerImpl) EmptyState() error
- func (p *PeerImpl) ExecuteTransaction(transaction *pb.Transaction) (response *pb.Response)
- func (p *PeerImpl) GetBlockByNumber(blockNumber uint64) (*pb.Block, error)
- func (p *PeerImpl) GetBlockchainSize() uint64
- func (p *PeerImpl) GetCurrentStateHash() (stateHash []byte, err error)
- func (p *PeerImpl) GetDiscHelper() discovery.Discovery
- func (p *PeerImpl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
- func (p *PeerImpl) GetPeers() (*pb.PeersMessage, error)
- func (p *PeerImpl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error)
- func (p *PeerImpl) GetSecHelper() crypto.Peer
- func (p *PeerImpl) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
- func (p *PeerImpl) GetStateSnapshot() (*state.StateSnapshot, error)
- func (p *PeerImpl) HashBlock(block *pb.Block) ([]byte, error)
- func (p *PeerImpl) Load(key string) ([]byte, error)
- func (p *PeerImpl) LoadDiscoveryList() ([]string, error)
- func (p *PeerImpl) NewOpenchainDiscoveryHello() (*pb.Message, error)
- func (p *PeerImpl) PeersDiscovered(peersMessage *pb.PeersMessage) error
- func (p *PeerImpl) ProcessTransaction(ctx context.Context, tx *pb.Transaction) (response *pb.Response, err error)
- func (p *PeerImpl) PutBlock(blockNumber uint64, block *pb.Block) error
- func (p *PeerImpl) RegisterHandler(messageHandler MessageHandler) error
- func (p *PeerImpl) RollbackStateDelta(id interface{}) error
- func (p *PeerImpl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)
- func (p *PeerImpl) Store(key string, value []byte) error
- func (p *PeerImpl) StoreDiscoveryList() error
- func (p *PeerImpl) Unicast(msg *pb.Message, receiverHandle *pb.PeerID) error
- func (p *PeerImpl) VerifyBlockchain(start, finish uint64) (uint64, error)
- type Persistor
- type RemoteLedger
- type SecurityAccessor
- type StateAccessor
- type StateRetriever
- type TransactionProccesor
Constants ¶
This section is empty.
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)
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
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) (MessageHandler, error)
HandlerFactory for creating new MessageHandlers
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, nextHandler MessageHandler) (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 PeerImpl ¶
type PeerImpl struct {
// contains filtered or unexported fields
}
PeerImpl implementation of the Peer service
func NewPeerWithEngine ¶
func NewPeerWithEngine(secHelperFunc func() crypto.Peer, engFactory EngineFactory) (peer *PeerImpl, 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) (*PeerImpl, error)
NewPeerWithHandler returns a Peer which uses the supplied handler factory function for creating new handlers on new Chat service invocations.
func (*PeerImpl) ApplyStateDelta ¶
func (p *PeerImpl) 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 (*PeerImpl) 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 (*PeerImpl) Chat ¶
func (p *PeerImpl) Chat(stream pb.Peer_ChatServer) error
Chat implementation of the the Chat bidi streaming RPC function
func (*PeerImpl) CommitStateDelta ¶
CommitStateDelta makes the result of ApplyStateDelta permanent and releases the resources necessary to rollback the delta
func (*PeerImpl) DeregisterHandler ¶
func (p *PeerImpl) DeregisterHandler(messageHandler MessageHandler) error
DeregisterHandler deregisters an already registered MessageHandler for this coordinator
func (*PeerImpl) EmptyState ¶
EmptyState completely empties the state and prepares it to restore a snapshot
func (*PeerImpl) ExecuteTransaction ¶
func (p *PeerImpl) ExecuteTransaction(transaction *pb.Transaction) (response *pb.Response)
ExecuteTransaction executes transactions decides to do execute in dev or prod mode
func (*PeerImpl) GetBlockByNumber ¶
GetBlockByNumber return a block by block number
func (*PeerImpl) GetBlockchainSize ¶
GetBlockchainSize returns the height/length of the blockchain
func (*PeerImpl) GetCurrentStateHash ¶
GetCurrentStateHash returns the current non-committed hash of the in memory state
func (*PeerImpl) GetDiscHelper ¶
GetDiscHelper enables a peer to retrieve its discovery object
func (*PeerImpl) GetPeerEndpoint ¶
func (p *PeerImpl) GetPeerEndpoint() (*pb.PeerEndpoint, error)
GetPeerEndpoint returns the endpoint for this peer
func (*PeerImpl) GetPeers ¶
func (p *PeerImpl) GetPeers() (*pb.PeersMessage, error)
GetPeers returns the currently registered PeerEndpoints
func (*PeerImpl) GetRemoteLedger ¶
func (p *PeerImpl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error)
GetRemoteLedger returns the RemoteLedger interface for the remote Peer Endpoint
func (*PeerImpl) GetSecHelper ¶
GetSecHelper returns the crypto.Peer
func (*PeerImpl) GetStateDelta ¶
func (p *PeerImpl) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
GetStateDelta return the state delta for the requested block number
func (*PeerImpl) GetStateSnapshot ¶
func (p *PeerImpl) GetStateSnapshot() (*state.StateSnapshot, error)
GetStateSnapshot return the state snapshot
func (*PeerImpl) Load ¶
Load enables a peer to read the value that corresponds to the given database key
func (*PeerImpl) LoadDiscoveryList ¶
LoadDiscoveryList enables a peer to load the discovery list from the database
func (*PeerImpl) NewOpenchainDiscoveryHello ¶
NewOpenchainDiscoveryHello constructs a new HelloMessage for sending
func (*PeerImpl) PeersDiscovered ¶
func (p *PeerImpl) PeersDiscovered(peersMessage *pb.PeersMessage) error
PeersDiscovered used by MessageHandlers for notifying this coordinator of discovered PeerEndoints. May include this Peer's PeerEndpoint.
func (*PeerImpl) ProcessTransaction ¶
func (p *PeerImpl) ProcessTransaction(ctx context.Context, tx *pb.Transaction) (response *pb.Response, err error)
ProcessTransaction implementation of the ProcessTransaction RPC function
func (*PeerImpl) PutBlock ¶
PutBlock inserts a raw block into the blockchain at the specified index, nearly no error checking is performed
func (*PeerImpl) RegisterHandler ¶
func (p *PeerImpl) RegisterHandler(messageHandler MessageHandler) error
RegisterHandler register a MessageHandler with this coordinator
func (*PeerImpl) RollbackStateDelta ¶
RollbackStateDelta undoes the results of ApplyStateDelta to revert the current state back to the state before ApplyStateDelta was invoked
func (*PeerImpl) SendTransactionsToPeer ¶
func (p *PeerImpl) SendTransactionsToPeer(peerAddress string, transaction *pb.Transaction) (response *pb.Response)
SendTransactionsToPeer forwards transactions to the specified peer address.
func (*PeerImpl) StoreDiscoveryList ¶
StoreDiscoveryList enables a peer to persist the discovery list to the database
func (*PeerImpl) VerifyBlockchain ¶
VerifyBlockchain checks the integrity of the blockchain between indices start and finish, returning the first block who's PreviousBlockHash field does not match the hash of the previous block
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