Documentation ¶
Overview ¶
Copyright 2018 The mesh-chain Authors
Index ¶
- Variables
- func GetInteractiveABI() map[string]abi.ABI
- func GetMESHBalanceKey(addr common.Address) common.Hash
- type API
- type Snapshot
- type StateFn
- type Tribe
- func (t *Tribe) APIs(chain consensus.ChainReader) []rpc.API
- func (t *Tribe) Author(header *types.Header) (common.Address, error)
- func (t *Tribe) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (t *Tribe) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (t *Tribe) GetConfig() *params.TribeConfig
- func (self *Tribe) GetMinerAddress() common.Address
- func (self *Tribe) GetMinerAddressByChan(rtn chan common.Address)
- func (t *Tribe) Init(fn StateFn, nodekey *ecdsa.PrivateKey)
- func (t *Tribe) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (t *Tribe) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (t *Tribe) SetConfig(config *params.TribeConfig)
- func (t *Tribe) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (t *Tribe) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (t *Tribe) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (t *Tribe) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type TribeMiner
Constants ¶
This section is empty.
Variables ¶
var ( ValidatorsContractName = "validators" PomContractName = "pom" )
var ( // ErrInvalidTimestamp is returned if the timestamp of a block is lower than // the previous block's timestamp + the minimum block period. ErrInvalidTimestamp = errors.New("invalid timestamp") ErrInvalidTimestampSIP002 = errors.New("invalid timestamp (SIP002)") // for tribe consensus block validator ErrTribeNotAllowEmptyTxList = errors.New("tribe not allow empty tx list") ErrTribeMustContainChiefTx = errors.New("tribe must contain chief tx") ErrTribeChiefVolunteerLowBalance = errors.New("tribe chief volunteer low balance") ErrTribeChiefVolunteerFail = errors.New("tribe chief volunteer check fail") ErrTribeChiefTxMustAtPositionZero = errors.New("tribe chief tx must at postion 0") ErrTribeChiefTxSignerAndBlockSignerNotMatch = errors.New("tribe chief update tx signer and block signer not match") ErrTribeValdateTxSenderCannotInSignerList = errors.New("tx sender cannot in signerlist") BlockRewardReducedInterval = 2102400 MeshRewardForValidator, _ = new(big.Int).SetString("114000000000000000000", 10) //Block reward in wei for successfully mining a block MeshRewardForPom, _ = new(big.Int).SetString("17580000000000000000000", 10) //Block reward in wei for successfully mining a block )
Various error messages to mark blocks invalid. These should be private to prevent engine specific errors from being referenced in the remainder of the codebase, inherently breaking if the engine is swapped out. Please put common error types into the consensus package.
Functions ¶
func GetInteractiveABI ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) GetMiner ¶
func (api *API) GetMiner() (*TribeMiner, error)
type Snapshot ¶
type Snapshot struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash common.Hash `json:"hash"` // Block hash where the snapshot was created Validators map[common.Address]struct{} `json:"validators"` // Set of authorized validators at this moment // contains filtered or unexported fields }
Snapshot is the state of the random pos validators at a given epoch time.
type Tribe ¶
type Tribe struct {
// contains filtered or unexported fields
}
func (*Tribe) APIs ¶
func (t *Tribe) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.
func (*Tribe) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*Tribe) CalcDifficulty ¶
func (t *Tribe) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have based on the previous blocks in the chain and the current signer.
func (*Tribe) Finalize ¶
func (t *Tribe) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*Tribe) GetConfig ¶
func (t *Tribe) GetConfig() *params.TribeConfig
func (*Tribe) GetMinerAddress ¶
func (*Tribe) GetMinerAddressByChan ¶
func (*Tribe) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Tribe) Seal ¶
func (t *Tribe) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.
func (*Tribe) SetConfig ¶
func (t *Tribe) SetConfig(config *params.TribeConfig)
func (*Tribe) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules.
func (*Tribe) VerifyHeaders ¶
func (t *Tribe) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).
func (*Tribe) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements. don't support remote miner agent, these code never reached
func (*Tribe) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.