// Consenter用于从网络接收消息 // 每一个consensus插件需要实现这个接口 type Consenter interface { RecvMsg(msg *pb.OpenchainMessage, senderHandle *pb.PeerID) error }
// Inquirer 用于获取有关网络网络的验证信息 type Inquirer interface { GetNetworkInfo() (self *pb.PeerEndpoint, network []*pb.PeerEndpoint, err error) GetNetworkHandles() (self *pb.PeerID, network []*pb.PeerID, err error) }
// Communicator 用于发送消息给其他验证端 type Communicator interface { Broadcast(msg *pb.OpenchainMessage, peerType pb.PeerEndpoint_Type) error Unicast(msg *pb.OpenchainMessage, receiverHandle *pb.PeerID) error }
// SecurityUtils 用于访问标志/验证crypto包中的方法 type SecurityUtils interface { Sign(msg []byte) ([]byte, error) Verify(peerID *pb.PeerID, signature []byte, message []byte) error }
// ReadOnlyLedger 用于询问区块链 type ReadOnlyLedger interface { GetBlock(id uint64) (block *pb.Block, err error) GetCurrentStateHash() (stateHash []byte, err error) GetBlockchainSize() (uint64, error) }
// UtilLedger 包含询问区块链的附加的实用功能 type UtilLedger interface { HashBlock(block *pb.Block) ([]byte, error) VerifyBlockchain(start, finish uint64) (uint64, error) }
// WritableLedger is 用户更新转移blockchain状态过程 type WritableLedger interface { PutBlock(blockNumber uint64, block *pb.Block) error ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error CommitStateDelta(id interface{}) error RollbackStateDelta(id interface{}) error EmptyState() error }
// Ledger is 一个不受限制的读取、效用和更新的联合 type Ledger interface { ReadOnlyLedger UtilLedger WritableLedger }
// Executor is 用于调用交易接口,有可能修改依托总账 type Executor interface { BeginTxBatch(id interface{}) error ExecTxs(id interface{}, txs []*pb.Transaction) ([]byte, error) CommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error) RollbackTxBatch(id interface{}) error PreviewCommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error) }
// RemoteLedgers is 用于查询blockchain的其他副本 type RemoteLedgers interface { GetRemoteBlocks(replicaID *pb.PeerID, start, finish uint64) (<-chan *pb.SyncBlocks, error) GetRemoteStateSnapshot(replicaID *pb.PeerID) (<-chan *pb.SyncStateSnapshot, error) GetRemoteStateDeltas(replicaID *pb.PeerID, start, finish uint64) (<-chan *pb.SyncStateDeltas, error) }
// LedgerStack 用作面向blockchain的活动接口,诸如执行交易,查询和更新总账 type LedgerStack interface { Executor Ledger RemoteLedgers }
// Stack 可用于consensus插件的一套面向堆栈的方法 type Stack interface { Inquirer Communicator SecurityUtils LedgerStack }
|