Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Consensus
- type Execution
- type MockExecution
- type MockMsgService
- func (m *MockMsgService) BroadcastProposal(blk *core.Block) error
- func (m *MockMsgService) BroadcastQC(qc *core.QuorumCert) error
- func (m *MockMsgService) RequestBlock(pubKey *core.PublicKey, hash []byte) (*core.Block, error)
- func (m *MockMsgService) RequestBlockByHeight(pubKey *core.PublicKey, height uint64) (*core.Block, error)
- func (m *MockMsgService) RequestQC(pubKey *core.PublicKey, blkHash []byte) (*core.QuorumCert, error)
- func (m *MockMsgService) SendQC(pubKey *core.PublicKey, qc *core.QuorumCert) error
- func (m *MockMsgService) SendVote(pubKey *core.PublicKey, vote *core.Vote) error
- func (m *MockMsgService) SubscribeProposal(buffer int) *emitter.Subscription
- func (m *MockMsgService) SubscribeQC(buffer int) *emitter.Subscription
- func (m *MockMsgService) SubscribeVote(buffer int) *emitter.Subscription
- type MockStorage
- func (m *MockStorage) Commit(data *storage.CommitData) error
- func (m *MockStorage) GetBlock(hash []byte) (*core.Block, error)
- func (m *MockStorage) GetBlockHeight() uint64
- func (m *MockStorage) GetLastBlock() (*core.Block, error)
- func (m *MockStorage) GetLastQC() (*core.QuorumCert, error)
- func (m *MockStorage) GetMerkleRoot() []byte
- func (m *MockStorage) GetQC(blkHash []byte) (*core.QuorumCert, error)
- func (m *MockStorage) HasTx(hash []byte) bool
- func (m *MockStorage) StoreBlock(blk *core.Block) error
- func (m *MockStorage) StoreQC(qc *core.QuorumCert) error
- type MockTxPool
- func (m *MockTxPool) GetStatus() txpool.Status
- func (m *MockTxPool) GetTx(hash []byte) *core.Transaction
- func (m *MockTxPool) GetTxStatus(hash []byte) txpool.TxStatus
- func (m *MockTxPool) GetTxsFromQueue(max int) [][]byte
- func (m *MockTxPool) GetTxsToExecute(hashes [][]byte) ([]*core.Transaction, [][]byte)
- func (m *MockTxPool) PopTxsFromQueue(max int) [][]byte
- func (m *MockTxPool) PutTxsToQueue(hashes [][]byte)
- func (m *MockTxPool) RemoveTxs(hashes [][]byte)
- func (m *MockTxPool) SetTxsPending(hashes [][]byte)
- func (m *MockTxPool) StoreTxs(txs *core.TxList) error
- func (m *MockTxPool) SubmitTx(tx *core.Transaction) error
- func (m *MockTxPool) SyncTxs(peer *core.PublicKey, hashes [][]byte) error
- type MsgService
- type Resources
- type Status
- type Storage
- type TxPool
Constants ¶
View Source
const ( FlagDebug = "debug" FlagDataDir = "dataDir" FlagChainID = "chainID" FlagBroadcastTx = "broadcastTx" FlagPointPort = "pointPort" FlagTopicPort = "topicPort" FlagAPIPort = "apiPort" // storage section FlagMerkleBranchFactor = "storage-merkleBranchFactor" // execution section FlagTxExecTimeout = "execution-txExecTimeout" FlagExecConcurrentLimit = "execution-concurrentLimit" // consensus section FlagBlockTxLimit = "consensus-blockTxLimit" FlagTxWaitTime = "consensus-txWaitTime" FlagViewWidth = "consensus-viewWidth" FlagLeaderTimeout = "consensus-leaderTimeout" FlagVoteStrategy = "consensus-voteStrategy" FlagBenchmarkPath = "consensus-benchmarkPath" )
View Source
const ( AverageVote uint8 = iota RandomVote OrdinaryVote MonopolyVote )
View Source
const ExecuteTxFlag = true // set to false when benchmark test
View Source
const PreserveTxFlag = false // set to true when benchmark test
View Source
const TwoPhaseBFTFlag = false // set to true to execute two-phase BFT protocol
Variables ¶
View Source
var DefaultConfig = Config{ BlockTxLimit: 500, TxWaitTime: 500 * time.Millisecond, ViewWidth: 60 * time.Second, LeaderTimeout: 5 * time.Second, VoteStrategy: AverageVote, BenchmarkPath: "", }
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ChainID int64 DataDir string // copy from node config // maximum tx count in a block BlockTxLimit int // proposal creation delay if no transactions in the pool TxWaitTime time.Duration // view duration for a leader ViewWidth time.Duration // leader must create next qc within this duration LeaderTimeout time.Duration // voting strategy adopted by validator VoteStrategy uint8 // path to save the benchmark log of the consensus algorithm (it will not be saved if blank) BenchmarkPath string }
type Execution ¶
type Execution interface { Execute(blk *core.Block, txs []*core.Transaction) (*core.BlockCommit, []*core.TxCommit) MockExecute(blk *core.Block) (*core.BlockCommit, []*core.TxCommit) }
type MockExecution ¶
func (*MockExecution) Execute ¶
func (m *MockExecution) Execute(blk *core.Block, txs []*core.Transaction) (*core.BlockCommit, []*core.TxCommit)
func (*MockExecution) MockExecute ¶
func (m *MockExecution) MockExecute(blk *core.Block) (*core.BlockCommit, []*core.TxCommit)
type MockMsgService ¶
func (*MockMsgService) BroadcastProposal ¶
func (m *MockMsgService) BroadcastProposal(blk *core.Block) error
func (*MockMsgService) BroadcastQC ¶
func (m *MockMsgService) BroadcastQC(qc *core.QuorumCert) error
func (*MockMsgService) RequestBlock ¶
func (*MockMsgService) RequestBlockByHeight ¶
func (*MockMsgService) RequestQC ¶
func (m *MockMsgService) RequestQC(pubKey *core.PublicKey, blkHash []byte) (*core.QuorumCert, error)
func (*MockMsgService) SendQC ¶
func (m *MockMsgService) SendQC(pubKey *core.PublicKey, qc *core.QuorumCert) error
func (*MockMsgService) SubscribeProposal ¶
func (m *MockMsgService) SubscribeProposal(buffer int) *emitter.Subscription
func (*MockMsgService) SubscribeQC ¶
func (m *MockMsgService) SubscribeQC(buffer int) *emitter.Subscription
func (*MockMsgService) SubscribeVote ¶
func (m *MockMsgService) SubscribeVote(buffer int) *emitter.Subscription
type MockStorage ¶
func (*MockStorage) Commit ¶
func (m *MockStorage) Commit(data *storage.CommitData) error
func (*MockStorage) GetBlockHeight ¶
func (m *MockStorage) GetBlockHeight() uint64
func (*MockStorage) GetLastBlock ¶
func (m *MockStorage) GetLastBlock() (*core.Block, error)
func (*MockStorage) GetLastQC ¶
func (m *MockStorage) GetLastQC() (*core.QuorumCert, error)
func (*MockStorage) GetMerkleRoot ¶
func (m *MockStorage) GetMerkleRoot() []byte
func (*MockStorage) GetQC ¶
func (m *MockStorage) GetQC(blkHash []byte) (*core.QuorumCert, error)
func (*MockStorage) HasTx ¶
func (m *MockStorage) HasTx(hash []byte) bool
func (*MockStorage) StoreBlock ¶
func (m *MockStorage) StoreBlock(blk *core.Block) error
func (*MockStorage) StoreQC ¶
func (m *MockStorage) StoreQC(qc *core.QuorumCert) error
type MockTxPool ¶
func (*MockTxPool) GetStatus ¶
func (m *MockTxPool) GetStatus() txpool.Status
func (*MockTxPool) GetTx ¶
func (m *MockTxPool) GetTx(hash []byte) *core.Transaction
func (*MockTxPool) GetTxStatus ¶
func (m *MockTxPool) GetTxStatus(hash []byte) txpool.TxStatus
func (*MockTxPool) GetTxsFromQueue ¶
func (m *MockTxPool) GetTxsFromQueue(max int) [][]byte
func (*MockTxPool) GetTxsToExecute ¶
func (m *MockTxPool) GetTxsToExecute(hashes [][]byte) ([]*core.Transaction, [][]byte)
func (*MockTxPool) PopTxsFromQueue ¶
func (m *MockTxPool) PopTxsFromQueue(max int) [][]byte
func (*MockTxPool) PutTxsToQueue ¶
func (m *MockTxPool) PutTxsToQueue(hashes [][]byte)
func (*MockTxPool) RemoveTxs ¶
func (m *MockTxPool) RemoveTxs(hashes [][]byte)
func (*MockTxPool) SetTxsPending ¶
func (m *MockTxPool) SetTxsPending(hashes [][]byte)
func (*MockTxPool) SubmitTx ¶
func (m *MockTxPool) SubmitTx(tx *core.Transaction) error
type MsgService ¶
type MsgService interface { BroadcastProposal(blk *core.Block) error BroadcastQC(qc *core.QuorumCert) error SendVote(pubKey *core.PublicKey, vote *core.Vote) error RequestBlock(pubKey *core.PublicKey, hash []byte) (*core.Block, error) RequestBlockByHeight(pubKey *core.PublicKey, height uint64) (*core.Block, error) RequestQC(pubKey *core.PublicKey, blkHash []byte) (*core.QuorumCert, error) SendQC(pubKey *core.PublicKey, qc *core.QuorumCert) error SubscribeProposal(buffer int) *emitter.Subscription SubscribeVote(buffer int) *emitter.Subscription SubscribeQC(buffer int) *emitter.Subscription }
type Status ¶
type Status struct { StartTime int64 CommittedTxCount int // committed tx count since node is up BlockPoolSize int QCPoolSize int ViewStart int64 // start timestamp of current view ViewChange int32 LeaderIndex uint32 // current status (block height) BExec uint64 BLeaf uint64 QCHigh uint64 View uint32 }
type Storage ¶
type Storage interface { GetMerkleRoot() []byte Commit(data *storage.CommitData) error StoreBlock(blk *core.Block) error GetBlock(hash []byte) (*core.Block, error) GetLastBlock() (*core.Block, error) StoreQC(qc *core.QuorumCert) error GetQC(blkHash []byte) (*core.QuorumCert, error) GetLastQC() (*core.QuorumCert, error) GetBlockHeight() uint64 HasTx(hash []byte) bool }
type TxPool ¶
type TxPool interface { SubmitTx(tx *core.Transaction) error StoreTxs(txs *core.TxList) error PopTxsFromQueue(max int) [][]byte GetTxsFromQueue(max int) [][]byte SetTxsPending(hashes [][]byte) GetTxsToExecute(hashes [][]byte) ([]*core.Transaction, [][]byte) RemoveTxs(hashes [][]byte) PutTxsToQueue(hashes [][]byte) SyncTxs(peer *core.PublicKey, hashes [][]byte) error GetTx(hash []byte) *core.Transaction GetStatus() txpool.Status GetTxStatus(hash []byte) txpool.TxStatus }
Click to show internal directories.
Click to hide internal directories.