tribe

package
v0.0.0-...-4f77113 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

Copyright 2018 The mesh-chain Authors

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidatorsContractName = "validators"
	PomContractName        = "pom"
)
View Source
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")
	ErrInvalidTimestampSIP002 = errors.New("invalid timestamp (SIP002)")

	// for tribe consensus block validator
	ErrTribeNotAllowEmptyTxList                 = errors.New("tribe not allow empty tx list")
	ErrTribeMustContainChiefTx                  = errors.New("tribe must contain chief tx")
	ErrTribeChiefVolunteerLowBalance            = errors.New("tribe chief volunteer low balance")
	ErrTribeChiefVolunteerFail                  = errors.New("tribe chief volunteer check fail")
	ErrTribeChiefTxMustAtPositionZero           = errors.New("tribe chief tx must at postion 0")
	ErrTribeChiefTxSignerAndBlockSignerNotMatch = errors.New("tribe chief update tx signer and block signer not match")
	ErrTribeValdateTxSenderCannotInSignerList   = errors.New("tx sender cannot in signerlist")

	BlockRewardReducedInterval = 2102400
	MeshRewardForValidator, _  = new(big.Int).SetString("114000000000000000000", 10)   //Block reward in wei for successfully mining a block
	MeshRewardForPom, _        = new(big.Int).SetString("17580000000000000000000", 10) //Block reward in wei for successfully mining a block
)

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

func GetInteractiveABI

func GetInteractiveABI() map[string]abi.ABI

func GetMESHBalanceKey

func GetMESHBalanceKey(addr common.Address) common.Hash

Types

type API

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

func (*API) BindInfo

func (api *API) BindInfo(addr *common.Address, num *big.Int) (map[string]interface{}, error)

func (*API) BindSign

func (api *API) BindSign(from *common.Address) (string, error)

func (*API) GetMiner

func (api *API) GetMiner() (*TribeMiner, error)

func (*API) GetValidators

func (api *API) GetValidators(number *big.Int) ([]common.Address, error)

type Snapshot

type Snapshot struct {
	Number     uint64                      `json:"number"`     // Block number where the snapshot was created
	Hash       common.Hash                 `json:"hash"`       // Block hash where the snapshot was created
	Validators map[common.Address]struct{} `json:"validators"` // Set of authorized validators at this moment
	// contains filtered or unexported fields
}

Snapshot is the state of the random pos validators at a given epoch time.

type StateFn

type StateFn func(hash common.Hash) (*state.StateDB, error)

StateFn gets state by the state root hash.

type Tribe

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

func New

func New(accman *accounts.Manager, 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

func (t *Tribe) 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 (*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) GetConfig

func (t *Tribe) GetConfig() *params.TribeConfig

func (*Tribe) GetMinerAddress

func (self *Tribe) GetMinerAddress() common.Address

func (*Tribe) GetMinerAddressByChan

func (self *Tribe) GetMinerAddressByChan(rtn chan common.Address)

func (*Tribe) Init

func (t *Tribe) Init(fn StateFn, nodekey *ecdsa.PrivateKey)

func (*Tribe) Prepare

func (t *Tribe) 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 (*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) SetConfig

func (t *Tribe) SetConfig(config *params.TribeConfig)

func (*Tribe) VerifyHeader

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

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

func (t *Tribe) 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. don't support remote miner agent, these code never reached

func (*Tribe) VerifyUncles

func (t *Tribe) 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 TribeMiner

type TribeMiner struct {
	Address common.Address `json:"address"`
	Balance *big.Int       `json:"balance"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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