{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v0.6.1-preview","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package consensus\n\n## Types\n\n```go\ntype Communicator interface {\n\tBroadcast(msg *pb.Message, peerType pb.PeerEndpoint_Type) error\n\tUnicast(msg *pb.Message, receiverHandle *pb.PeerID) error\n}\n```\nCommunicator is used to send messages to other validators\n\n```go\ntype Consenter interface {\n\tRecvMsg(msg *pb.Message, senderHandle *pb.PeerID) error // Called serially with incoming messages from gRPC\n\tExecutionConsumer\n}\n```\nConsenter is used to receive messages from the network Every consensus plugin needs to implement this interface\n\n```go\ntype ExecutionConsumer interface {\n\tExecuted(tag interface{})                                // Called whenever Execute completes\n\tCommitted(tag interface{}, target *pb.BlockchainInfo)    // Called whenever Commit completes\n\tRolledBack(tag interface{})                              // Called whenever a Rollback completes\n\tStateUpdated(tag interface{}, target *pb.BlockchainInfo) // Called when state transfer completes, if target is nil, this indicates a failure and a new target should be supplied\n}\n```\nExecutionConsumer allows callbacks from asycnhronous execution and statetransfer\n\n```go\ntype Executor interface {\n\tStart()                                                                     // Bring up the resources needed to use this interface\n\tHalt()                                                                      // Tear down the resources needed to use this interface\n\tExecute(tag interface{}, txs []*pb.Transaction)                             // Executes a set of transactions, this may be called in succession\n\tCommit(tag interface{}, metadata []byte)                                    // Commits whatever transactions have been executed\n\tRollback(tag interface{})                                                   // Rolls back whatever transactions have been executed\n\tUpdateState(tag interface{}, target *pb.BlockchainInfo, peers []*pb.PeerID) // Attempts to synchronize state to a particular target, implicitly calls rollback if needed\n}\n```\nExecutor is intended to eventually supplant the old Executor interface The problem with invoking the calls directly above, is that they must be coordinated with state transfer, to eliminate possible races and ledger corruption\n\n```go\ntype Inquirer interface {\n\tGetNetworkInfo() (self *pb.PeerEndpoint, network []*pb.PeerEndpoint, err error)\n\tGetNetworkHandles() (self *pb.PeerID, network []*pb.PeerID, err error)\n}\n```\nInquirer is used to retrieve info about the validating network\n\n```go\ntype LedgerManager interface {\n\tInvalidateState() // Invalidate informs the ledger that it is out of date and should reject queries\n\tValidateState()   // Validate informs the ledger that it is back up to date and should resume replying to queries\n}\n```\nLedgerManager is used to manipulate the state of the ledger\n\n```go\ntype LegacyExecutor interface {\n\tBeginTxBatch(id interface{}) error\n\tExecTxs(id interface{}, txs []*pb.Transaction) ([]byte, error)\n\tCommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error)\n\tRollbackTxBatch(id interface{}) error\n\tPreviewCommitTxBatch(id interface{}, metadata []byte) ([]byte, error)\n}\n```\nLegacyExecutor is used to invoke transactions, potentially modifying the backing ledger\n\n```go\ntype NetworkStack interface {\n\tCommunicator\n\tInquirer\n}\n```\nNetworkStack is used to retrieve network info and send messages\n\n```go\ntype ReadOnlyLedger interface {\n\tGetBlock(id uint64) (block *pb.Block, err error)\n\tGetBlockchainSize() uint64\n\tGetBlockchainInfo() *pb.BlockchainInfo\n\tGetBlockchainInfoBlob() []byte\n\tGetBlockHeadMetadata() ([]byte, error)\n}\n```\nReadOnlyLedger is used for interrogating the blockchain\n\n```go\ntype SecurityUtils interface {\n\tSign(msg []byte) ([]byte, error)\n\tVerify(peerID *pb.PeerID, signature []byte, message []byte) error\n}\n```\nSecurityUtils is used to access the sign/verify methods from the crypto package\n\n```go\ntype Stack interface {\n\tNetworkStack\n\tSecurityUtils\n\tExecutor\n\tLegacyExecutor\n\tLedgerManager\n\tReadOnlyLedger\n\tStatePersistor\n}\n```\nStack is the set of stack-facing methods available to the consensus plugin\n\n```go\ntype StatePersistor interface {\n\tStoreState(key string, value []byte) error\n\tReadState(key string) ([]byte, error)\n\tReadStateSet(prefix string) (map[string][]byte, error)\n\tDelState(key string)\n}\n```\nStatePersistor is used to store consensus state which should survive a process crash\n\n","path":"github.com/eric-erki/https-hyperledger.org/consensus","name":"consensus","synopsis":"","isRedistributable":true}
