Documentation ¶
Index ¶
- func AddCoinActualRewards(state *state.StateDB, coinrewards *big.Int)
- func AddStorageActualRewards(state *state.StateDB, storagerewards *big.Int)
- func AddTotalActualRewards(state *state.StateDB, rewards *big.Int)
- func CalcDifficulty(snap *CommitteeSnapshot, addr common.Address, blockNumber uint64) *big.Int
- func CreateCommitteeRankByte(address []common.Address) []byte
- func Ecrecover(header *types.Header) (common.Address, error)
- func GetCoinActualRewards(state *state.StateDB) *big.Int
- func GetCommiteeWrittenBlockNumberByTurn(config *params.GenaroConfig, turn uint64) uint64
- func GetCommitteeAccountBinding(header *types.Header) (committeeAccountBinding map[common.Address][]common.Address)
- func GetDependTurnByBlockNumber(config *params.GenaroConfig, number uint64) uint64
- func GetFirstBlockNumberOfEpoch(config *params.GenaroConfig, epochNumber uint64) uint64
- func GetHeaderCommitteeRankList(header *types.Header) ([]common.Address, []uint64)
- func GetLastBlockNumberOfEpoch(config *params.GenaroConfig, epochNumber uint64) uint64
- func GetPreCoinActualRewards(state *state.StateDB) *big.Int
- func GetPreStorageActualRewards(state *state.StateDB) *big.Int
- func GetPreSurplusCoin(state *state.StateDB) *big.Int
- func GetStorageActualRewards(state *state.StateDB) *big.Int
- func GetSurplusCoin(state *state.StateDB) *big.Int
- func GetTotalActualRewards(state *state.StateDB) *big.Int
- func GetTurnOfCommiteeByBlockNumber(config *params.GenaroConfig, number uint64) uint64
- func IsBackStakeBlockNumber(config *params.GenaroConfig, applyBlockNumber, nowBlockNumber uint64) bool
- func ResetHeaderSignature(header *types.Header)
- func SetCoinActualRewards(state *state.StateDB, coinrewards *big.Int)
- func SetCommitteeAccountBinding(header *types.Header, ...) error
- func SetHeaderCommitteeRankList(header *types.Header, committeeRank []common.Address, proportion []uint64) error
- func SetHeaderSignature(header *types.Header, signature []byte)
- func SetPreCoinActualRewards(state *state.StateDB, coinrewards *big.Int)
- func SetPreStorageActualRewards(state *state.StateDB, storagerewards *big.Int)
- func SetPreSurplusCoin(state *state.StateDB, surplusrewards *big.Int)
- func SetStorageActualRewards(state *state.StateDB, storagerewards *big.Int)
- func SetSurplusCoin(state *state.StateDB, surplusrewards *big.Int)
- func SetTotalActualRewards(state *state.StateDB, rewards *big.Int)
- func SubSurplusCoin(state *state.StateDB, rewards *big.Int)
- type API
- type CommitteeSnapshot
- type ExtraData
- type Genaro
- func (g *Genaro) APIs(chain consensus.ChainReader) []rpc.API
- func (g *Genaro) Author(header *types.Header) (common.Address, error)
- func (g *Genaro) Authorize(signer common.Address, signFn SignerFn)
- func (g *Genaro) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (g *Genaro) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (g *Genaro) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (g *Genaro) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (g *Genaro) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (g *Genaro) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (g *Genaro) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (g *Genaro) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type SignerFn
- type Stake
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddStorageActualRewards ¶
func CalcDifficulty ¶
CalcDifficulty return the distance between my index and intern-index depend on snap
func CreateCommitteeRankByte ¶
func GetCommiteeWrittenBlockNumberByTurn ¶
func GetCommiteeWrittenBlockNumberByTurn(config *params.GenaroConfig, turn uint64) uint64
get the written BlockNumber by the turn of committee
func GetDependTurnByBlockNumber ¶
func GetDependTurnByBlockNumber(config *params.GenaroConfig, number uint64) uint64
get the depend turn from block number
func GetFirstBlockNumberOfEpoch ¶
func GetFirstBlockNumberOfEpoch(config *params.GenaroConfig, epochNumber uint64) uint64
func GetLastBlockNumberOfEpoch ¶
func GetLastBlockNumberOfEpoch(config *params.GenaroConfig, epochNumber uint64) uint64
func GetTurnOfCommiteeByBlockNumber ¶
func GetTurnOfCommiteeByBlockNumber(config *params.GenaroConfig, number uint64) uint64
get the committee turn from block number
func IsBackStakeBlockNumber ¶
func IsBackStakeBlockNumber(config *params.GenaroConfig, applyBlockNumber, nowBlockNumber uint64) bool
func ResetHeaderSignature ¶
func SetHeaderSignature ¶
func SetPreCoinActualRewards ¶
func SetStorageActualRewards ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow controlling the signer and voting mechanisms of the proof-of-authority scheme.
func (*API) GetBlockCommittee ¶
GetCommittee return the member of committee
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(epochNumber uint64) (*CommitteeSnapshot, error)
GetSnapshot retrieves the state snapshot at a given epochNumber.
type CommitteeSnapshot ¶
type CommitteeSnapshot struct { WriteBlockNumber uint64 // Block number where the snapshot was created WriteBlockHash common.Hash // BlockHash as the snapshot key EpochNumber uint64 // the turn of Committee CommitteeSize uint64 // the size of Committee CommitteeRank []common.Address // the rank of committee Committee map[common.Address]uint64 // committee members CommitteeAccountBinding map[common.Address][]common.Address // account binding map // contains filtered or unexported fields }
Each turn has a Snapshot. EpochNumber means the "electoral materials" period. Snapshot will not be stored immediately. It will be stored in EpochNumber + ElectionPeriod Snapshot will be valid in EpochNumber + ElectionPeriod + ValidPeriod
type ExtraData ¶
type ExtraData struct { CommitteeRank []common.Address `json:"committeeRank"` // rank of committee LastSynBlockNum uint64 `json:"lastBlockNum"` LastSynBlockHash common.Hash `json:"lastSynBlockHash"` Signature []byte `json:"signature"` // the signature of block broadcaster Proportion []uint64 `json:"ratio"` CommitteeAccountBinding map[common.Address][]common.Address `json:"CommitteeAccountBinding"` // 委员会账号的绑定信息 }
the field "extra" store the json of ExtraData
func UnmarshalToExtra ¶
type Genaro ¶
type Genaro struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *params.GenaroConfig, snapshotDb ethdb.Database) *Genaro
New creates a Genaro consensus engine
func (*Genaro) APIs ¶
func (g *Genaro) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API
func (*Genaro) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*Genaro) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*Genaro) CalcDifficulty ¶
func (g *Genaro) 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 (*Genaro) Finalize ¶
func (g *Genaro) 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 (*Genaro) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Genaro) Seal ¶
func (g *Genaro) 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 (*Genaro) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.
func (*Genaro) VerifyHeaders ¶
func (g *Genaro) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. 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 (*Genaro) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Genaro) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.