Documentation
¶
Overview ¶
Copyright 2018 The Proton Authors
Index ¶
- Constants
- Variables
- type API
- func (api *API) GetHistory(last *big.Int, noRpc *bool) (interface{}, error)
- func (api *API) GetMiner(number *rpc.BlockNumber) (*TribeMiner, error)
- func (api *API) GetSigners(hash *common.Hash) ([]*Signer, error)
- func (api *API) GetSinners(hash *common.Hash) ([]common.Address, error)
- func (api *API) GetStatus(hash *common.Hash) (*TribeStatus, error)
- func (api *API) GetVolunteers(hash *common.Hash) (*TribeVolunteers, error)
- type History
- type Signer
- type SignerFn
- type Tribe
- func (t *Tribe) APIs(chain consensus.ChainReader) []rpc.API
- func (t *Tribe) Author(header *types.Header) (a common.Address, e error)
- func (t *Tribe) Authorize(signer common.Address, signFn SignerFn)
- 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) GetPeriod(header *types.Header, signers []*Signer) (p uint64)
- func (t *Tribe) Init(hash common.Hash, number *big.Int)
- 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) SetMining(i int32, currentNumber *big.Int, currentBlockHash common.Hash)
- 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
- func (t *Tribe) WaitingNomination() chan struct{}
- type TribeMiner
- type TribeStatus
- func (self *TribeStatus) GetMinerAddress() common.Address
- func (self *TribeStatus) GetSigners() []*Signer
- func (self *TribeStatus) GetSignersFromChiefByHash(hash common.Hash, number *big.Int) ([]*Signer, error)
- func (self *TribeStatus) InTurnForCalc(signer common.Address, parent *types.Header) *big.Int
- func (self *TribeStatus) InTurnForVerify(number int64, parentHash common.Hash, signer common.Address) *big.Int
- func (self *TribeStatus) LoadSignersFromChief(hash common.Hash, number *big.Int) error
- func (self *TribeStatus) String() string
- func (self *TribeStatus) Update(currentNumber *big.Int, hash common.Hash)
- func (self *TribeStatus) ValidateBlock(parent, block *types.Block, validateSigner bool) error
- func (self *TribeStatus) ValidateSigner(parentHeader, header *types.Header, signer common.Address) bool
- type TribeVolunteers
- type Volunteer
Constants ¶
const ( // None -> Volunteer -> Signer -> Sinner LevelNone = "None" LevelVolunteer = "Volunteer" LevelSigner = "Signer" LevelSinner = "Sinner" CHIEF_NUMBER = int64(2) )
Variables ¶
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") // for tribe consensus block validator ErrTribeNotAllowEmptyTxList = errors.New("tribe not allow empty tx list") ErrTribeMustContainChiefTx = errors.New("tribe must contain chief tx") ErrTribeChiefCannotRepeat = errors.New("tribe chief tx cannot repeat") )
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 ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) GetHistory ¶
func (*API) GetMiner ¶
func (api *API) GetMiner(number *rpc.BlockNumber) (*TribeMiner, error)
func (*API) GetSinners ¶
chief-0.0.3 show blacklist
func (*API) GetVolunteers ¶
func (api *API) GetVolunteers(hash *common.Hash) (*TribeVolunteers, error)
type Signer ¶
type SignerFn ¶
SignerFn is a signer callback function to request a hash to be signed by a backing account.
type Tribe ¶
type Tribe struct {
Status *TribeStatus
SealErrorCh map[int64]error // when error from seal fun, may be need commit a new work
// contains filtered or unexported fields
}
func New ¶
func New(config *params.TribeConfig, db ethdb.Database) *Tribe
signers set to the ones provided by the user.
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) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
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) 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) 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.
func (*Tribe) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
func (*Tribe) WaitingNomination ¶
func (t *Tribe) WaitingNomination() chan struct{}
called by miner.start
type TribeMiner ¶
type TribeStatus ¶
type TribeStatus struct {
Signers []*Signer `json:"signers"`
Volunteers []common.Address `json:"volunteers"` // Discarded on vsn 0.0.6
TotalVolunteer *big.Int `json:"totalVolunteer"` // add by vsn 0.0.6
SignerLevel string `json:"signerLevel"` // None -> Volunteer -> Signer
Number int64 `json:"number"` // last block.number
BlackListLen int `json:"totalSinner"` // length of blacklist
// for watch the set method result
Epoch *big.Int `json:"epoch"`
SignerLimit *big.Int `json:"signerLimit"`
VolunteerLimit *big.Int `json:"volunteerLimit"`
Vsn string `json:"version"` // chief version
// contains filtered or unexported fields
}
func NewTribeStatus ¶
func NewTribeStatus() *TribeStatus
func (*TribeStatus) GetMinerAddress ¶
func (self *TribeStatus) GetMinerAddress() common.Address
func (*TribeStatus) GetSigners ¶
func (self *TribeStatus) GetSigners() []*Signer
func (*TribeStatus) GetSignersFromChiefByHash ¶
func (*TribeStatus) InTurnForCalc ¶
func (*TribeStatus) InTurnForVerify ¶
func (*TribeStatus) LoadSignersFromChief ¶
在 加载完所有 node.service 后,需要主动调用一次
func (*TribeStatus) String ¶
func (self *TribeStatus) String() string
func (*TribeStatus) Update ¶
func (self *TribeStatus) Update(currentNumber *big.Int, hash common.Hash)
called by end of WriteBlockAndState if miner then execute chief.update and chief.getStatus else execute chief.getStatus only
func (*TribeStatus) ValidateBlock ¶
func (self *TribeStatus) ValidateBlock(parent, block *types.Block, validateSigner bool) error
every block sync download or mine check chief tx