genaro

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2019 License: GPL-3.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCoinActualRewards

func AddCoinActualRewards(state *state.StateDB, coinrewards *big.Int)

func AddStorageActualRewards

func AddStorageActualRewards(state *state.StateDB, storagerewards *big.Int)

func AddTotalActualRewards

func AddTotalActualRewards(state *state.StateDB, rewards *big.Int)

func CalcDifficulty

func CalcDifficulty(snap *CommitteeSnapshot, addr common.Address, blockNumber uint64) *big.Int

CalcDifficulty return the distance between my index and intern-index depend on snap

func CreateCommitteeRankByte

func CreateCommitteeRankByte(address []common.Address) []byte

func Ecrecover

func Ecrecover(header *types.Header) (common.Address, error)

func GetCoinActualRewards

func GetCoinActualRewards(state *state.StateDB) *big.Int

func GetCommiteeWrittenBlockNumberByTurn

func GetCommiteeWrittenBlockNumberByTurn(config *params.GenaroConfig, turn uint64) uint64

get the written BlockNumber by the turn of committee

func GetCommitteeAccountBinding

func GetCommitteeAccountBinding(header *types.Header) (committeeAccountBinding map[common.Address][]common.Address)

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 GetHeaderCommitteeRankList

func GetHeaderCommitteeRankList(header *types.Header) ([]common.Address, []uint64)

func GetLastBlockNumberOfEpoch

func GetLastBlockNumberOfEpoch(config *params.GenaroConfig, epochNumber uint64) uint64

func GetPreCoinActualRewards

func GetPreCoinActualRewards(state *state.StateDB) *big.Int

func GetPreStorageActualRewards

func GetPreStorageActualRewards(state *state.StateDB) *big.Int

func GetPreSurplusCoin

func GetPreSurplusCoin(state *state.StateDB) *big.Int

func GetStorageActualRewards

func GetStorageActualRewards(state *state.StateDB) *big.Int

func GetSurplusCoin

func GetSurplusCoin(state *state.StateDB) *big.Int

func GetTotalActualRewards

func GetTotalActualRewards(state *state.StateDB) *big.Int

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 ResetHeaderSignature(header *types.Header)

func SetCoinActualRewards

func SetCoinActualRewards(state *state.StateDB, coinrewards *big.Int)

func SetCommitteeAccountBinding

func SetCommitteeAccountBinding(header *types.Header, committeeAccountBinding map[common.Address][]common.Address) error

func SetHeaderCommitteeRankList

func SetHeaderCommitteeRankList(header *types.Header, committeeRank []common.Address, proportion []uint64) error

func SetHeaderSignature

func SetHeaderSignature(header *types.Header, signature []byte)

func SetPreCoinActualRewards

func SetPreCoinActualRewards(state *state.StateDB, coinrewards *big.Int)

func SetPreStorageActualRewards

func SetPreStorageActualRewards(state *state.StateDB, storagerewards *big.Int)

func SetPreSurplusCoin

func SetPreSurplusCoin(state *state.StateDB, surplusrewards *big.Int)

func SetStorageActualRewards

func SetStorageActualRewards(state *state.StateDB, storagerewards *big.Int)

func SetSurplusCoin

func SetSurplusCoin(state *state.StateDB, surplusrewards *big.Int)

func SetTotalActualRewards

func SetTotalActualRewards(state *state.StateDB, rewards *big.Int)

func SubSurplusCoin

func SubSurplusCoin(state *state.StateDB, rewards *big.Int)

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

func (api *API) GetBlockCommittee(epochNumber uint64) []common.Address

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

func UnmarshalToExtra(header *types.Header) *ExtraData

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

func (g *Genaro) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.

func (*Genaro) Authorize

func (g *Genaro) Authorize(signer common.Address, signFn SignerFn)

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

func (g *Genaro) Prepare(chain consensus.ChainReader, header *types.Header) error

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

func (g *Genaro) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

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

func (g *Genaro) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*Genaro) VerifyUncles

func (g *Genaro) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

type SignerFn

type SignerFn func(accounts.Account, []byte) ([]byte, error)

SignerFn is a signer callback function to request a hash to be signed by a backing account.

type Stake

type Stake struct {
	BlockNumber uint64
	Amount      uint64
	Staker      common.Address
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL