Documentation ¶
Index ¶
- Constants
- Variables
- func BlockShareNum(getter serodb.Getter, block common.Hash) (num uint64)
- func CalcHash256PRNGIV(seed []byte) common.Hash
- func FindShareIdxs(size uint32, n uint16, prng *Hash256PRNG) ([]uint32, error)
- func GetBlockRecords(getter serodb.Getter, blockHash common.Hash, blockNumber uint64) (shares []*Share, pools []*StakePool)
- func GetLockingBlockNum() uint64
- func GetPoolValueThreshold() *big.Int
- func GetPosRewardBySize(size uint64, blockNumber int64) (soloRewards *big.Int, totalRewards *big.Int)
- func InitAVLTree(state State)
- type AVLTree
- type Hash256PRNG
- type ITree
- type Node
- type STree
- type Share
- func GetShare(getter serodb.Getter, hash common.Hash) *Share
- func GetShareByBlockNumber(getter serodb.Getter, id common.Hash, blockHash common.Hash, ...) *Share
- func GetSharesByBlock(getter serodb.Getter, blockHash common.Hash, blockNumber uint64) (shares []*Share)
- func SeleteBlockShare(getter serodb.Getter, block common.Hash) (idx []uint32, shares []*Share)
- type StakePool
- type StakeState
- func (self *StakeState) AddPendingShare(share *Share)
- func (self *StakeState) AddStakePool(pool *StakePool)
- func (self *StakeState) CaleAvgPrice(amount *big.Int) (uint32, *big.Int, *big.Int)
- func (self *StakeState) CheckVotes(block *types.Block, bc blockChain) error
- func (self *StakeState) CurrentPrice() *big.Int
- func (self *StakeState) GetShare(key common.Hash) *Share
- func (self *StakeState) GetStakePool(poolId common.Hash) *StakePool
- func (self *StakeState) GetStakeState(key common.Hash) common.Hash
- func (self *StakeState) NeedTwoVote(num uint64) bool
- func (self *StakeState) ProcessBeforeApply(bc blockChain, header *types.Header) (err error)
- func (self *StakeState) RecordVotes(batch serodb.Batch, block *types.Block) error
- func (self *StakeState) SeleteShare(seed common.Hash, blockNumber uint64) (ints []uint32, shares []*Share, err error)
- func (self *StakeState) SetStakeState(key common.Hash, value common.Hash)
- func (self *StakeState) ShareSize() uint32
- func (self *StakeState) StakeCurrentReward(blockNumber *big.Int) (soloRewards *big.Int, totalRewards *big.Int)
- func (self *StakeState) SumAmount(n int64) *big.Int
- type State
- type Status
Constants ¶
const ( SOLO_RATE = 3 TOTAL_RATE = 4 MaxVoteCount = 3 ValidVoteCount = 2 )
Variables ¶
var ( StakePoolDB = consensus.DBObj{"STAKE$POOL$"} )
Functions ¶
func CalcHash256PRNGIV ¶
CalcHash256PRNGIV calculates and returns the initialization vector for a given seed. This can be used in conjunction with the NewHash256PRNGFromIV function to arrive at the same values that are produced when calling NewHash256PRNG with the seed.
func FindShareIdxs ¶
func FindShareIdxs(size uint32, n uint16, prng *Hash256PRNG) ([]uint32, error)
FindShareIdxs is the exported version of findShareIdxs used for testing.
func GetBlockRecords ¶
func GetLockingBlockNum ¶
func GetLockingBlockNum() uint64
func GetPoolValueThreshold ¶
func GetPosRewardBySize ¶
func InitAVLTree ¶
func InitAVLTree(state State)
Types ¶
type AVLTree ¶
type AVLTree struct {
// contains filtered or unexported fields
}
func CopyFromOldV0 ¶
func CopyFromOldV1 ¶
func NewAVLTree ¶
func (*AVLTree) Midtraverse ¶
func (tree *AVLTree) Midtraverse()
type Hash256PRNG ¶
type Hash256PRNG struct {
// contains filtered or unexported fields
}
Hash256PRNG is a determinstic pseudorandom number generator that uses a 256-bit secure hashing function to generate random uint32s starting from an initial seed.
func NewHash256PRNG ¶
func NewHash256PRNG(seed []byte) *Hash256PRNG
NewHash256PRNG returns a deterministic pseudorandom number generator that uses a 256-bit secure hashing function to generate random uint32s given a seed.
func NewHash256PRNGFromIV ¶
func NewHash256PRNGFromIV(iv common.Hash) *Hash256PRNG
NewHash256PRNGFromIV returns a deterministic pseudorandom number generator that uses a 256-bit secure hashing function to generate random uint32s given an initialization vector. The CalcHash256PRNGIV can be used to calculate an initialization vector for a given seed such that the generator will produce the same values as if NewHash256PRNG were called with the same seed. This allows callers to cache and reuse the initialization vector for a given seed to avoid recomputation.
func (*Hash256PRNG) Hash256Rand ¶
func (hp *Hash256PRNG) Hash256Rand() uint32
Hash256Rand returns a uint32 random number using the pseudorandom number generator and updates the state.
func (*Hash256PRNG) StateHash ¶
func (hp *Hash256PRNG) StateHash() common.Hash
StateHash returns a hash referencing the current state the deterministic PRNG.
type ITree ¶
type STree ¶
type STree struct {
// contains filtered or unexported fields
}
func (*STree) Lasttraverse ¶
func (*STree) Midtraverse ¶
func (tree *STree) Midtraverse()
type Share ¶
type Share struct {}
func GetShareByBlockNumber ¶
func GetSharesByBlock ¶
func SeleteBlockShare ¶
type StakePool ¶
type StakePool struct { PKr c_type.PKr VotePKr c_type.PKr BlockNumber uint64 TransactionHash common.Hash Amount *big.Int `rlp:"nil"` Fee uint16 WishVoteNum uint32 MissedVoteNum uint32 ExpireNum uint32 Income *big.Int `rlp:"nil"` Profit *big.Int `rlp:"nil"` LastPayTime uint64 Closed bool }
type StakeState ¶
type StakeState struct {
// contains filtered or unexported fields
}
func NewStakeState ¶
func NewStakeState(statedb *state.StateDB) *StakeState
func (*StakeState) AddPendingShare ¶
func (self *StakeState) AddPendingShare(share *Share)
func (*StakeState) AddStakePool ¶
func (self *StakeState) AddStakePool(pool *StakePool)
func (*StakeState) CaleAvgPrice ¶
func (*StakeState) CheckVotes ¶
func (self *StakeState) CheckVotes(block *types.Block, bc blockChain) error
func (*StakeState) CurrentPrice ¶
func (self *StakeState) CurrentPrice() *big.Int
func (*StakeState) GetStakePool ¶
func (self *StakeState) GetStakePool(poolId common.Hash) *StakePool
func (*StakeState) GetStakeState ¶
func (self *StakeState) GetStakeState(key common.Hash) common.Hash
func (*StakeState) NeedTwoVote ¶
func (self *StakeState) NeedTwoVote(num uint64) bool
func (*StakeState) ProcessBeforeApply ¶
func (self *StakeState) ProcessBeforeApply(bc blockChain, header *types.Header) (err error)
func (*StakeState) RecordVotes ¶
func (*StakeState) SeleteShare ¶
func (*StakeState) SetStakeState ¶
func (self *StakeState) SetStakeState(key common.Hash, value common.Hash)
func (*StakeState) ShareSize ¶
func (self *StakeState) ShareSize() uint32