Documentation ¶
Index ¶
- Variables
- func Genesis(cfg *Config, state *state.StateDB, height uint64) error
- type API
- func (api *API) Account(name string) (interface{}, error)
- func (api *API) Epcho(height uint64) (interface{}, error)
- func (api *API) Info() (interface{}, error)
- func (api *API) Irreversible() (interface{}, error)
- func (api *API) LatestEpcho() (interface{}, error)
- func (api *API) Producers() ([]map[string]interface{}, error)
- func (api *API) ValidateEpcho() (interface{}, error)
- type ChangeProducer
- type Config
- type Dpos
- func (dpos *Dpos) APIs(chain consensus.IChainReader) []rpc.API
- func (dpos *Dpos) Author(header *types.Header) (common.Name, error)
- func (dpos *Dpos) BlockInterval() uint64
- func (dpos *Dpos) CalcDifficulty(chain consensus.IChainReader, time uint64, parent *types.Header) *big.Int
- func (dpos *Dpos) Config() *Config
- func (dpos *Dpos) Engine() consensus.IEngine
- func (dpos *Dpos) Finalize(chain consensus.IChainReader, header *types.Header, txs []*types.Transaction, ...) (*types.Block, error)
- func (dpos *Dpos) IsFirst(timestamp uint64) bool
- func (dpos *Dpos) IsValidateProducer(chain consensus.IChainReader, height uint64, timestamp uint64, producer string, ...) error
- func (dpos *Dpos) Prepare(chain consensus.IChainReader, header *types.Header, txs []*types.Transaction, ...) error
- func (dpos *Dpos) ProcessAction(chainCfg *params.ChainConfig, state *state.StateDB, action *types.Action) error
- func (dpos *Dpos) Seal(chain consensus.IChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (dpos *Dpos) SetConfig(config *Config)
- func (dpos *Dpos) SetSignFn(signFn SignFn)
- func (dpos *Dpos) Slot(timestamp uint64) uint64
- func (dpos *Dpos) VerifySeal(chain consensus.IChainReader, header *types.Header) error
- type IDB
- type IDatabase
- type Irreversible_Ret
- type LDB
- func (db *LDB) DelProducer(name string) error
- func (db *LDB) DelState(height uint64) error
- func (db *LDB) DelVoter(name string, producer string) error
- func (db *LDB) GetProducer(name string) (*producerInfo, error)
- func (db *LDB) GetState(height uint64) (*globalState, error)
- func (db *LDB) GetVoter(name string) (*voterInfo, error)
- func (db *LDB) Producers() ([]*producerInfo, error)
- func (db *LDB) ProducersSize() (uint64, error)
- func (db *LDB) SetProducer(producer *producerInfo) error
- func (db *LDB) SetState(gstate *globalState) error
- func (db *LDB) SetVoter(voter *voterInfo) error
- type RegisterProducer
- type RemoveVoter
- type SignFn
- type System
- func (sys *System) ChangeProducer(voter string, producer string) error
- func (sys *System) RegProducer(producer string, url string, stake *big.Int) error
- func (sys *System) UnregProducer(producer string) error
- func (sys *System) UnvoteProducer(voter string) error
- func (sys *System) UnvoteVoter(producer string, voter string) error
- func (sys *System) UpdateProducer(producer string, url string, stake *big.Int) error
- func (sys *System) VoteProducer(voter string, producer string, stake *big.Int) error
- type UInt64Slice
- type UpdateProducer
- type VoteProducer
Constants ¶
This section is empty.
Variables ¶
var ( ErrIllegalProducerName = errors.New("illegal producer name") ErrIllegalProducerPubKey = errors.New("illegal producer pubkey") )
var ( // ProducerKeyPrefix producer name --> producerInfo ProducerKeyPrefix = "prod" // VoterKeyPrefix voter name ---> voterInfo VoterKeyPrefix = "vote" // // DelegatorKeyPrfix producer name ----> voter names // DelegatorKeyPrfix = "dele" // ProducersKeyPrefix produces ----> producer names ProducersKeyPrefix = "prods" // StateKeyPrefix height --> globalState StateKeyPrefix = "state" // Separator Split characters Separator = "_" // ProducersKey producers ProducersKey = "prods" // ProducersSizeKey producers size ProducersSizeKey = "prodsize" // LastestStateKey lastest LastestStateKey = "lastest" )
var DefaultConfig = &Config{ MaxURLLen: 512, UnitStake: big.NewInt(1000), ProducerMinQuantity: big.NewInt(10), VoterMinQuantity: big.NewInt(1), ActivatedMinQuantity: big.NewInt(100), BlockInterval: 3000, BlockFrequency: 6, ProducerScheduleSize: 3, DelayEcho: 2, AccountName: "ftsystemdpos", SystemName: "ftsystemio", SystemURL: "www.fractalproject.com", ExtraBlockReward: big.NewInt(1), BlockReward: big.NewInt(5), Decimals: 18, }
DefaultConfig configures
var ( // LastBlockHeight latest LastBlockHeight = uint64(math.MaxUint64) )
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes dpos related methods for the RPC interface.
func (*API) Irreversible ¶
func (*API) LatestEpcho ¶
func (*API) ValidateEpcho ¶
type ChangeProducer ¶
type ChangeProducer struct {
Producer string
}
type Config ¶
type Config struct { // consensus fileds MaxURLLen uint64 // url length UnitStake *big.Int // state unit ProducerMinQuantity *big.Int // min quantity VoterMinQuantity *big.Int // min quantity ActivatedMinQuantity *big.Int // min active quantity BlockInterval uint64 BlockFrequency uint64 ProducerScheduleSize uint64 DelayEcho uint64 AccountName string SystemName string SystemURL string ExtraBlockReward *big.Int BlockReward *big.Int Decimals uint64 // contains filtered or unexported fields }
Config dpos configures
type Dpos ¶
type Dpos struct {
// contains filtered or unexported fields
}
Dpos dpos engine
func New ¶
func New(config *Config, chain consensus.IChainReader) *Dpos
New creates a DPOS consensus engine
func (*Dpos) APIs ¶
func (dpos *Dpos) APIs(chain consensus.IChainReader) []rpc.API
APIs returning the user facing RPC APIs.
func (*Dpos) CalcDifficulty ¶
func (dpos *Dpos) CalcDifficulty(chain consensus.IChainReader, time uint64, parent *types.Header) *big.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.
func (*Dpos) Finalize ¶
func (dpos *Dpos) Finalize(chain consensus.IChainReader, header *types.Header, txs []*types.Transaction, receipts []*types.Receipt, state *state.StateDB) (*types.Block, error)
Finalize assembles the final block.
func (*Dpos) IsValidateProducer ¶
func (dpos *Dpos) IsValidateProducer(chain consensus.IChainReader, height uint64, timestamp uint64, producer string, pubkeys [][]byte, state *state.StateDB) error
IsValidateProducer current producer
func (*Dpos) Prepare ¶
func (dpos *Dpos) Prepare(chain consensus.IChainReader, header *types.Header, txs []*types.Transaction, receipts []*types.Receipt, state *state.StateDB) error
Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.
func (*Dpos) ProcessAction ¶
func (*Dpos) Seal ¶
func (dpos *Dpos) Seal(chain consensus.IChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal generates a new block for the given input block with the local miner's seal place on top.
func (*Dpos) VerifySeal ¶
VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.
type IDB ¶
type IDB interface { SetProducer(*producerInfo) error DelProducer(string) error GetProducer(string) (*producerInfo, error) Producers() ([]*producerInfo, error) ProducersSize() (uint64, error) SetVoter(*voterInfo) error DelVoter(string, string) error GetVoter(string) (*voterInfo, error) SetState(*globalState) error DelState(uint64) error GetState(uint64) (*globalState, error) Delegate(string, *big.Int) error Undelegate(string, *big.Int) error IncAsset2Acct(string, string, *big.Int) error }
IDB dpos database
type IDatabase ¶
type IDatabase interface { Get(key string) ([]byte, error) Put(key string, value []byte) error Delete(key string) error Delegate(string, *big.Int) error Undelegate(string, *big.Int) error IncAsset2Acct(string, string, *big.Int) error }
IDatabase level db
type Irreversible_Ret ¶
type LDB ¶
type LDB struct {
IDatabase
}
LDB dpos level db
func (*LDB) DelProducer ¶
func (*LDB) GetProducer ¶
func (*LDB) ProducersSize ¶
func (*LDB) SetProducer ¶
type RegisterProducer ¶
type RemoveVoter ¶
type RemoveVoter struct {
Voter string
}
type System ¶
type System struct { IDB // contains filtered or unexported fields }
func (*System) ChangeProducer ¶
ChangeProducer change a producer
func (*System) RegProducer ¶
RegProducer register a producer
func (*System) UnregProducer ¶
UnregProducer unregister a producer
func (*System) UnvoteProducer ¶
UnvoteProducer cancel vote
func (*System) UnvoteVoter ¶
UnvoteVoter cancel voter
func (*System) UpdateProducer ¶
UpdateProducer update a producer
type UInt64Slice ¶
type UInt64Slice []uint64
UInt64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order.
func (UInt64Slice) Len ¶
func (s UInt64Slice) Len() int
func (UInt64Slice) Less ¶
func (s UInt64Slice) Less(i, j int) bool
func (UInt64Slice) Swap ¶
func (s UInt64Slice) Swap(i, j int)