Documentation ¶
Index ¶
- type Agreement
- type Block
- type BlockChain
- type BlockChainConsensue
- type BlockDAG
- type BlockHeader
- type ChainVM
- type Consensus
- type ConsensusAlgorithm
- type ConsensusState
- type Context
- type DAG
- type Decidable
- type FeeEstimator
- type Notify
- type Operation
- type PoA
- type PoW
- type Status
- type Tx
- type TxPool
- type VM
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agreement ¶
type Agreement interface { Commit(operation Operation) (ConsensusState, error) GetHeadState() (ConsensusState, error) Rollback(state ConsensusState) error }
agree on a operation that update the consensus state
type BlockChain ¶
type BlockChain interface { }
type BlockChainConsensue ¶
type BlockChainConsensue interface { // VerifySeal checks whether the crypto seal on a header is valid according to // the consensus rules of the given engine. Verify(chain BlockChain, header BlockHeader) error // Prepare initializes the consensus fields of a block header according to the // rules of a particular engine. The changes are executed inline. Prepare(chain BlockChain, header BlockHeader) error // Finalize runs any post-transaction state modifications (e.g. block rewards) // and assembles the final block. // Note: The block header and state database might be updated to reflect any // consensus rules that happen at finalization (e.g. block rewards). Finalize() (Block, error) // Generates a new block for the given input block with the local miner's // seal place on top. Generate(chain BlockChain, block Block, stop <-chan struct{}) (Block, error) }
the algorithm agnostic consensus engine.
type BlockHeader ¶
type BlockHeader interface { }
type ChainVM ¶
type ChainVM interface { VM GetBlock(*hash.Hash) (Block, error) BuildBlock([]Tx) (Block, error) ParseBlock([]byte) (Block, error) LastAccepted() (*hash.Hash, error) GetBalance(string) (int64, error) VerifyTx(tx Tx) (int64, error) VerifyTxSanity(tx Tx) error AddTxToMempool(tx *types.Transaction, local bool) (int64, error) GetTxsFromMempool() ([]*types.Transaction, error) GetMempoolSize() int64 RemoveTxFromMempool(tx *types.Transaction) error CheckConnectBlock(block Block) error ConnectBlock(block Block) error DisconnectBlock(block Block) error ResetTemplate() error Genesis() *hash.Hash }
type Consensus ¶
type Consensus interface { GetCurrentState() (ConsensusState, error) Commit(state ConsensusState) (ConsensusState, error) SetAlgorithm(algorithm ConsensusAlgorithm) }
agree on a consensus state
type ConsensusAlgorithm ¶
type ConsensusAlgorithm interface {
SetState(state ConsensusState) (ConsensusState, error)
}
type FeeEstimator ¶
type Notify ¶
type Notify interface { AnnounceNewTransactions(newTxs []*types.TxDesc, filters []peer.ID) RelayInventory(data interface{}, filters []peer.ID) BroadcastMessage(data interface{}) TransactionConfirmed(tx *types.Tx) AddRebroadcastInventory(newTxs []*types.TxDesc) }
Notify interface manage message announce & relay & notification between mempool, websocket, gbt long pull and rpc server.
type Operation ¶
type Operation interface {
ApplyTo(state ConsensusState) (ConsensusState, error)
}
type PoA ¶
type PoA interface { BlockChainConsensue }
type PoW ¶
type PoW interface { BlockChainConsensue // CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty // that a new block should have. CalcDifficulty(chain BlockChain, time uint64, parent BlockHeader) *big.Int // Hashrate returns the current mining hashrate of a PoW consensus engine. Hashrate() float64 }
PoW is a consensus engine based on proof-of-work.
type TxPool ¶
type TxPool interface { RemoveTransaction(tx *types.Tx, removeRedeemers bool) RemoveDoubleSpends(tx *types.Tx) RemoveOrphan(txHash *hash.Hash) ProcessOrphans(hash *hash.Hash) []*types.TxDesc MaybeAcceptTransaction(tx *types.Tx, isNew, rateLimit bool) ([]*hash.Hash, error) HaveTransaction(hash *hash.Hash) bool PruneExpiredTx() ProcessTransaction(tx *types.Tx, allowOrphan, rateLimit, allowHighFees bool) ([]*types.TxDesc, error) GetMainHeight() int64 AddTransaction(tx *types.Tx, height uint64, fee int64) IsSupportVMTx() bool }
Click to show internal directories.
Click to hide internal directories.