Documentation
¶
Index ¶
- func APosProto(header block.IHeader) []byte
- func AccumulateRewards(r *Reward, number *uint256.Int, chain consensus.ChainHeaderReader) (map[types.Address]*uint256.Int, map[types.Address]*uint256.Int, error)
- func New(config *params.APosConfig, db kv.RwDB, chainConfig *params.ChainConfig) consensus.Engine
- func NewFaker() consensus.Engine
- func SealHash(header block.IHeader) (hash types.Hash)
- type API
- func (api *API) Discard(address common.Address)
- func (api *API) GetAccountRewardUnpaid(address types.Address) (val *uint256.Int, err error)
- func (api *API) GetBlockRewards(blockNr jsonrpc.BlockNumberOrHash) (resp []*block.Reward, err error)
- func (api *API) GetDepositInfo(address common.Address) (*deposit.Info, error)
- func (api *API) GetMinedBlock(address common.Address, from jsonrpc.BlockNumberOrHash, wantCount uint64) (*MinedBlockResponse, error)
- func (api *API) GetRewards(address common.Address, from jsonrpc.BlockNumberOrHash, ...) (resp *RewardResponse, err error)
- func (api *API) GetSigner(rlpOrBlockNr *blockNumberOrHashOrRLP) (types.Address, error)
- func (api *API) GetSigners(number *jsonrpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetSignersAtHash(hash types.Hash) ([]common.Address, error)
- func (api *API) GetSnapshot(number *jsonrpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetSnapshotAtHash(hash types.Hash) (*Snapshot, error)
- func (api *API) Proposals() map[common.Address]bool
- func (api *API) Propose(address common.Address, auth bool)
- func (api *API) Status() (*status, error)
- func (api *API) VerifiedBlock(address common.Address, from jsonrpc.BlockNumberOrHash, wantCount uint64, ...) (*VerifiedBlockResponse, error)
- type APos
- func (c *APos) APIs(chain consensus.ChainReader) []jsonrpc.API
- func (c *APos) Author(header block.IHeader) (types.Address, error)
- func (c *APos) Authorize(signer types.Address, signFn SignerFn)
- func (c *APos) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent block.IHeader) *uint256.Int
- func (c *APos) Close() error
- func (c *APos) CountDepositor() uint64
- func (c *APos) Finalize(chain consensus.ChainHeaderReader, header block.IHeader, ...) ([]*block.Reward, map[types.Address]*uint256.Int, error)
- func (c *APos) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header block.IHeader, ...) (block.IBlock, []*block.Reward, map[types.Address]*uint256.Int, error)
- func (c *APos) IsServiceTransaction(sender types.Address, syscall consensus.SystemCall) bool
- func (c *APos) Prepare(chain consensus.ChainHeaderReader, header block.IHeader) error
- func (c *APos) Rewards(tx kv.RwTx, header block.IHeader, state *state.IntraBlockState, ...) ([]*block.Reward, error)
- func (c *APos) Seal(chain consensus.ChainHeaderReader, b block.IBlock, results chan<- block.IBlock, ...) error
- func (c *APos) SealHash(header block.IHeader) types.Hash
- func (c *APos) SetBlockChain(bc amcCommon.IBlockChain)
- func (c *APos) Type() params.ConsensusType
- func (c *APos) VerifyHeader(chain consensus.ChainHeaderReader, header block.IHeader, seal bool) error
- func (c *APos) VerifyHeaders(chain consensus.ChainHeaderReader, headers []block.IHeader, seals []bool) (chan<- struct{}, <-chan error)
- func (c *APos) VerifyUncles(chain consensus.ChainReader, block block.IBlock) error
- type AccountReward
- type AccountRewards
- type Faker
- func (f Faker) APIs(chain consensus.ChainReader) []jsonrpc.API
- func (f Faker) Author(header block.IHeader) (types.Address, error)
- func (f Faker) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent block.IHeader) *uint256.Int
- func (f Faker) Close() error
- func (f Faker) Finalize(chain consensus.ChainHeaderReader, header block.IHeader, ...) ([]*block.Reward, map[types.Address]*uint256.Int, error)
- func (f Faker) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header block.IHeader, ...) (block.IBlock, []*block.Reward, map[types.Address]*uint256.Int, error)
- func (f Faker) IsServiceTransaction(sender types.Address, syscall consensus.SystemCall) bool
- func (f Faker) Prepare(chain consensus.ChainHeaderReader, header block.IHeader) error
- func (f Faker) Rewards(tx kv.RwTx, header block.IHeader, state *state.IntraBlockState, ...) ([]*block.Reward, error)
- func (f Faker) Seal(chain consensus.ChainHeaderReader, block block.IBlock, ...) error
- func (f Faker) SealHash(header block.IHeader) types.Hash
- func (f Faker) Type() params.ConsensusType
- func (f Faker) VerifyHeader(chain consensus.ChainHeaderReader, header block.IHeader, seal bool) error
- func (f Faker) VerifyHeaders(chain consensus.ChainHeaderReader, headers []block.IHeader, seals []bool) (chan<- struct{}, <-chan error)
- func (f Faker) VerifyUncles(chain consensus.ChainReader, block block.IBlock) error
- type MinedBlock
- type MinedBlockResponse
- type Reward
- type RewardResponse
- type RewardResponseValue
- type RewardResponseValues
- type SignerFn
- type Snapshot
- type Tally
- type VerifiedBlockResponse
- type Vote
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccumulateRewards ¶
func New ¶
func New(config *params.APosConfig, db kv.RwDB, chainConfig *params.ChainConfig) consensus.Engine
New creates a APos proof-of-authority consensus engine with the initial signers set to the ones provided by the user.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing jsonrpc API to allow controlling the signer and voting mechanisms of the proof-of-authority scheme.
func (*API) Discard ¶
Discard drops a currently running proposal, stopping the signer from casting further votes (either for or against).
func (*API) GetAccountRewardUnpaid ¶
func (*API) GetBlockRewards ¶
func (api *API) GetBlockRewards(blockNr jsonrpc.BlockNumberOrHash) (resp []*block.Reward, err error)
GetRewards todo:needs check
func (*API) GetDepositInfo ¶
GetRewards
func (*API) GetMinedBlock ¶
func (api *API) GetMinedBlock(address common.Address, from jsonrpc.BlockNumberOrHash, wantCount uint64) (*MinedBlockResponse, error)
GetTasks
func (*API) GetRewards ¶
func (api *API) GetRewards(address common.Address, from jsonrpc.BlockNumberOrHash, to jsonrpc.BlockNumberOrHash) (resp *RewardResponse, err error)
GetRewards
func (*API) GetSigner ¶
GetSigner returns the signer for a specific Apos block. Can be called with either a blocknumber, blockhash or an rlp encoded blob. The RLP encoded blob can either be a block or a header.
func (*API) GetSigners ¶
GetSigners retrieves the list of authorized signers at the specified block.
func (*API) GetSignersAtHash ¶
GetSignersAtHash retrieves the list of authorized signers at the specified block.
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *jsonrpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
GetSnapshotAtHash retrieves the state snapshot at a given block.
func (*API) Proposals ¶
Proposals returns the current proposals the node tries to uphold and vote on.
func (*API) Propose ¶
Propose injects a new authorization proposal that the signer will attempt to push through.
func (*API) Status ¶
Status returns the status of the last N blocks, - the number of active signers, - the number of signers, - the percentage of in-turn blocks
func (*API) VerifiedBlock ¶
func (api *API) VerifiedBlock(address common.Address, from jsonrpc.BlockNumberOrHash, wantCount uint64, to *jsonrpc.BlockNumber) (*VerifiedBlockResponse, error)
VerifiedBlock
type APos ¶
type APos struct {
// contains filtered or unexported fields
}
APos is the proof-of-authority consensus engine proposed to support the Ethereum testnet following the Ropsten attacks.
func (*APos) APIs ¶
func (c *APos) APIs(chain consensus.ChainReader) []jsonrpc.API
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.
func (*APos) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*APos) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with. todo init
func (*APos) CalcDifficulty ¶
func (c *APos) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent block.IHeader) *uint256.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have: * DIFF_NOTURN(2) if BLOCK_NUMBER % SIGNER_COUNT != SIGNER_INDEX * DIFF_INTURN(1) if BLOCK_NUMBER % SIGNER_COUNT == SIGNER_INDEX
func (*APos) Close ¶
Close implements consensus.Engine. It's a noop for Apoa as there are no background threads.
func (*APos) CountDepositor ¶
func (*APos) Finalize ¶
func (c *APos) Finalize(chain consensus.ChainHeaderReader, header block.IHeader, state *state.IntraBlockState, txs []*transaction.Transaction, uncles []block.IHeader) ([]*block.Reward, map[types.Address]*uint256.Int, error)
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given.
func (*APos) FinalizeAndAssemble ¶
func (c *APos) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header block.IHeader, state *state.IntraBlockState, txs []*transaction.Transaction, uncles []block.IHeader, receipts []*block.Receipt) (block.IBlock, []*block.Reward, map[types.Address]*uint256.Int, error)
FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*APos) IsServiceTransaction ¶
func (*APos) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*APos) Seal ¶
func (c *APos) Seal(chain consensus.ChainHeaderReader, b block.IBlock, results chan<- block.IBlock, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.
func (*APos) SetBlockChain ¶
func (c *APos) SetBlockChain(bc amcCommon.IBlockChain)
func (*APos) Type ¶
func (c *APos) Type() params.ConsensusType
func (*APos) VerifyHeader ¶
func (c *APos) VerifyHeader(chain consensus.ChainHeaderReader, header block.IHeader, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules.
func (*APos) VerifyHeaders ¶
func (c *APos) VerifyHeaders(chain consensus.ChainHeaderReader, headers []block.IHeader, 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 (*APos) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
type AccountReward ¶
type AccountRewards ¶
type AccountRewards []*AccountReward
func (AccountRewards) Len ¶
func (r AccountRewards) Len() int
func (AccountRewards) Less ¶
func (r AccountRewards) Less(i, j int) bool
func (AccountRewards) Swap ¶
func (r AccountRewards) Swap(i, j int)
type Faker ¶
type Faker struct{}
func (Faker) CalcDifficulty ¶
func (Faker) Finalize ¶
func (f Faker) Finalize(chain consensus.ChainHeaderReader, header block.IHeader, state *state.IntraBlockState, txs []*transaction.Transaction, uncles []block.IHeader) ([]*block.Reward, map[types.Address]*uint256.Int, error)
func (Faker) FinalizeAndAssemble ¶
func (Faker) IsServiceTransaction ¶
func (Faker) Type ¶
func (f Faker) Type() params.ConsensusType
func (Faker) VerifyHeader ¶
func (Faker) VerifyHeaders ¶
func (Faker) VerifyUncles ¶
type MinedBlock ¶
type MinedBlockResponse ¶
type MinedBlockResponse struct { MinedBlocks []MinedBlock `json:"minedBlocks"` CurrentBlockNumber *uint256.Int `json:"currentBlockNumber"` }
type Reward ¶
type Reward struct {
// contains filtered or unexported fields
}
func (*Reward) GetRewards ¶
func (*Reward) SetRewards ¶
type RewardResponse ¶
type RewardResponse struct { Address types.Address `json:"address" yaml:"address"` Data RewardResponseValues `json:"data" yaml:"data"` Total *uint256.Int `json:"total" yaml:"total"` }
type RewardResponseValue ¶
type RewardResponseValues ¶
type RewardResponseValues []*RewardResponseValue
func (RewardResponseValues) Len ¶
func (r RewardResponseValues) Len() int
func (RewardResponseValues) Less ¶
func (r RewardResponseValues) Less(i, j int) bool
func (RewardResponseValues) Swap ¶
func (r RewardResponseValues) Swap(i, j int)
type SignerFn ¶
SignerFn hashes and signs the data to be signed by a backing account. todo types.address to account
type Snapshot ¶
type Snapshot struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash types.Hash `json:"hash"` // Block hash where the snapshot was created Signers map[types.Address]struct{} `json:"signers"` // Set of authorized signers at this moment Recents map[uint64]types.Address `json:"recents"` // Set of recent signers for spam protections Votes []*Vote `json:"votes"` // List of votes cast in chronological order Tally map[types.Address]Tally `json:"tally"` // Current vote tally to avoid recalculating // contains filtered or unexported fields }
Snapshot is the state of the authorization voting at a given point in time.
type Tally ¶
type Tally struct { Authorize bool `json:"authorize"` // Whether the vote is about authorizing or kicking someone Votes int `json:"votes"` // Number of votes until now wanting to pass the proposal }
Tally is a simple vote tally to keep the current score of votes. Votes that go against the proposal aren't counted since it's equivalent to not voting.
type VerifiedBlockResponse ¶
type VerifiedBlockResponse struct { MinedBlocks []MinedBlock `json:"minedBlocks"` Total *uint256.Int `json:"totalBlocks"` }
type Vote ¶
type Vote struct { Signer types.Address `json:"signer"` // Authorized signer that cast this vote Block uint64 `json:"block"` // Block number the vote was cast in (expire old votes) Address types.Address `json:"address"` // Account being voted on to change its authorization Authorize bool `json:"authorize"` // Whether to authorize or deauthorize the voted account }
Vote represents a single vote that an authorized signer made to modify the list of authorizations.