backend

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NewBlockMsg = 0x07
)

Variables

View Source
var (
	ErrInvalidVrfProve = errors.New("invalid vrf prove")
	ErrStorageNonce    = errors.New("storage previous nonce failed")
)

Functions

func CallSystemContractAtBlockNumber

func CallSystemContractAtBlockNumber(
	chain consensus.ChainReader,
	sb *backend,
	number uint64,
	sysContractAddr common.Address,
	sysFuncName string,
	sysFuncParams []interface{},
) []byte

func New

func New(config *params.IstanbulConfig, privateKey *ecdsa.PrivateKey, db dbhandle.Database) consensus.Iris

New creates an Ethereum backend for Iris core engine.

func ParseResultToExtractType

func ParseResultToExtractType(res []byte, v interface{}) interface{}

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API is a user facing RPC API to dump Iris state

func (*API) Candidates

func (api *API) Candidates(number *rpc.BlockNumber) ([]common.Address, error)

Candidates returns the current candidates the node tries to uphold and vote on.

func (*API) Discard

func (api *API) Discard(address common.Address)

Discard drops a currently running candidate, stopping the validator from casting further votes (either for or against).

func (*API) GetSnapshot

func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)

GetSnapshot retrieves the state snapshot at a given block.

func (*API) GetSnapshotAtHash

func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)

GetSnapshotAtHash retrieves the state snapshot at a given block.

func (*API) GetValidators

func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)

GetValidators retrieves the list of authorized validators at the specified block.

func (*API) GetValidatorsAtHash

func (api *API) GetValidatorsAtHash(hash common.Hash) ([]common.Address, error)

GetValidatorsAtHash retrieves the state snapshot at a given block.

func (*API) Propose

func (api *API) Propose(address common.Address, auth bool)

Propose injects a new authorization candidate that the validator will attempt to push through.

type ChainContext

type ChainContext struct {
	// contains filtered or unexported fields
}

func (*ChainContext) Engine

func (cc *ChainContext) Engine() consensus.Engine

func (*ChainContext) GetHeader

func (cc *ChainContext) GetHeader(hash common.Hash, number uint64) *types.Header

type Snapshot

type Snapshot struct {
	Number uint64                   // Block number where the snapshot was created
	Hash   common.Hash              // Block hash where the snapshot was created
	Votes  []*Vote                  // List of votes cast in chronological order
	Tally  map[common.Address]Tally // Current vote tally to avoid recalculating
	ValSet iris.ValidatorSet        // Set of authorized validators at this moment
}

Snapshot is the state of the authorization voting at a given point in time.

func (*Snapshot) MarshalJSON

func (s *Snapshot) MarshalJSON() ([]byte, error)

Marshal to a json byte array

func (*Snapshot) UnmarshalJSON

func (s *Snapshot) UnmarshalJSON(b []byte) error

Unmarshal from a json byte array

type Tally

type Tally struct {
	Authorize bool `json:"authorize"` // Whether the vote it 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 Vote

type Vote struct {
	Validator common.Address `json:"validator"` // Authorized validator that cast this vote
	Block     uint64         `json:"block"`     // Block number the vote was cast in (expire old votes)
	Address   common.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 validator made to modify the list of authorizations.

Jump to

Keyboard shortcuts

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