Documentation
¶
Index ¶
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 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 model.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 model.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 model.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)
GetBlockByNumber(num uint64) (Block, error)
BuildBlock([]model.Tx) (Block, error)
ParseBlock([]byte) (Block, error)
LastAccepted() (*hash.Hash, error)
GetBalance(string) (int64, error)
VerifyTx(tx model.Tx) (int64, error)
VerifyTxSanity(tx model.Tx) error
AddTxToMempool(tx *types.Transaction, local bool) (int64, error)
GetTxsFromMempool() ([]*types.Transaction, []*hash.Hash, error)
GetMempoolSize() int64
RemoveTxFromMempool(tx *types.Transaction) error
CheckConnectBlock(block Block) error
ConnectBlock(block Block) (uint64, error)
DisconnectBlock(block Block) (uint64, error)
RewindTo(state model.BlockState) error
ResetTemplate() error
Genesis() *hash.Hash
GetBlockIDByTxHash(txhash *hash.Hash) uint64
GetCurStateRoot() common.Hash
GetCurHeader() *etypes.Header
BlockChain() *core.BlockChain
ChainDatabase() ethdb.Database
PrepareEnvironment(state model.BlockState) (*etypes.Header, error)
HasTx(h *hash.Hash) bool
}
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 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 model.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.
Click to show internal directories.
Click to hide internal directories.