Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyGenesis(s *Store, index *topicsdb.Index)
- func OnNewLog(s *Store, l *types.Log)
- type DelegationID
- type EpochStats
- type SfcDelegation
- type SfcDelegationAndID
- type SfcStaker
- type SfcStakerAndID
- type Store
- func (s *Store) Close()
- func (s *Store) DelSfcDelegation(id DelegationID)
- func (s *Store) DelSfcStaker(stakerID idx.ValidatorID)
- func (s *Store) ForEachSfcDelegation(do func(SfcDelegationAndID))
- func (s *Store) ForEachSfcStaker(do func(SfcStakerAndID))
- func (s *Store) GetDelegationClaimedRewards(id DelegationID) *big.Int
- func (s *Store) GetEpochValidators(epoch idx.Epoch) []SfcStakerAndID
- func (s *Store) GetSfcDelegation(id DelegationID) *SfcDelegation
- func (s *Store) GetSfcDelegationsByAddr(addr common.Address, limit int) []SfcDelegationAndID
- func (s *Store) GetSfcStaker(stakerID idx.ValidatorID) *SfcStaker
- func (s *Store) GetSfcStakers() []SfcStakerAndID
- func (s *Store) GetStakerDelegationsClaimedRewards(stakerID idx.ValidatorID) *big.Int
- func (s *Store) HasEpochValidator(epoch idx.Epoch, stakerID idx.ValidatorID) bool
- func (s *Store) HasSfcStaker(stakerID idx.ValidatorID) bool
- func (s *Store) IncDelegationClaimedRewards(id DelegationID, diff *big.Int)
- func (s *Store) IncStakerDelegationsClaimedRewards(stakerID idx.ValidatorID, diff *big.Int)
- func (s *Store) SetDelegationClaimedRewards(id DelegationID, amount *big.Int)
- func (s *Store) SetEpochValidators(epoch idx.Epoch, vv []SfcStakerAndID)
- func (s *Store) SetSfcDelegation(id DelegationID, v *SfcDelegation)
- func (s *Store) SetSfcStaker(stakerID idx.ValidatorID, v *SfcStaker)
- func (s *Store) SetStakerDelegationsClaimedRewards(stakerID idx.ValidatorID, amount *big.Int)
Constants ¶
const (
// DelegationIDSize is size of DelegationID serialized object
DelegationIDSize = 20 + 4
)
Variables ¶
var ( // ForkBit is set if staker has a confirmed pair of fork events ForkBit = uint64(1) // OfflineBit is set if staker has didn't have confirmed events for a long time OfflineBit = uint64(1 << 8) // CheaterMask is a combination of severe misbehavings CheaterMask = ForkBit )
var ( // Topics of SFC contract logs Topics = struct { ClaimedRewards common.Hash RestakedRewards common.Hash ClaimedDelegationReward common.Hash ClaimedValidatorReward common.Hash CreatedValidator common.Hash DeactivatedValidator common.Hash ChangedValidatorStatus common.Hash Delegated common.Hash Undelegated common.Hash }{ ClaimedRewards: crypto.Keccak256Hash([]byte("ClaimedRewards(address,uint256,uint256,uint256,uint256)")), RestakedRewards: crypto.Keccak256Hash([]byte("RestakedRewards(address,uint256,uint256,uint256,uint256)")), ClaimedDelegationReward: crypto.Keccak256Hash([]byte("ClaimedDelegationReward(address,uint256,uint256,uint256,uint256)")), ClaimedValidatorReward: crypto.Keccak256Hash([]byte("ClaimedValidatorReward(uint256,uint256,uint256,uint256)")), CreatedValidator: crypto.Keccak256Hash([]byte("CreatedValidator(uint256,address,uint256,uint256)")), DeactivatedValidator: crypto.Keccak256Hash([]byte("DeactivatedValidator(uint256,uint256,uint256)")), ChangedValidatorStatus: crypto.Keccak256Hash([]byte("ChangedValidatorStatus(uint256,uint256)")), Delegated: crypto.Keccak256Hash([]byte("Delegated(address,uint256,uint256)")), Undelegated: crypto.Keccak256Hash([]byte("Undelegated(address,uint256,uint256,uint256)")), } )
Functions ¶
func ApplyGenesis ¶
Types ¶
type DelegationID ¶
type DelegationID struct { Delegator common.Address StakerID idx.ValidatorID }
DelegationID is a pair of delegator address and staker ID to which delegation is applied
func BytesToDelegationID ¶
func BytesToDelegationID(bb []byte) DelegationID
func (*DelegationID) Bytes ¶
func (id *DelegationID) Bytes() []byte
type EpochStats ¶
type EpochStats struct { Start inter.Timestamp End inter.Timestamp TotalFee *big.Int Epoch idx.Epoch `rlp:"-"` // API-only field TotalBaseRewardWeight *big.Int `rlp:"-"` // API-only field TotalTxRewardWeight *big.Int `rlp:"-"` // API-only field }
EpochStats stores general statistics for an epoch
func (*EpochStats) Duration ¶
func (s *EpochStats) Duration() inter.Timestamp
Duration returns epoch duration
type SfcDelegation ¶
type SfcDelegation struct { Amount *big.Int // API-only fields CreatedEpoch idx.Epoch `rlp:"-"` CreatedTime inter.Timestamp `rlp:"-"` DeactivatedEpoch idx.Epoch `rlp:"-"` DeactivatedTime inter.Timestamp `rlp:"-"` }
SfcDelegation is the node-side representation of SFC delegation
type SfcDelegationAndID ¶
type SfcDelegationAndID struct { Delegation *SfcDelegation ID DelegationID }
SfcDelegationAndID is pair SfcDelegation + address
type SfcStaker ¶
type SfcStaker struct { CreatedEpoch idx.Epoch CreatedTime inter.Timestamp DeactivatedEpoch idx.Epoch DeactivatedTime inter.Timestamp Address common.Address Status uint64 // API-only fields StakeAmount *big.Int `rlp:"-"` DelegatedMe *big.Int `rlp:"-"` IsValidator bool `rlp:"-"` }
SfcStaker is the node-side representation of SFC staker
func (*SfcStaker) CalcTotalStake ¶
CalcTotalStake returns sum of staker's stake and delegated to staker stake
type SfcStakerAndID ¶
type SfcStakerAndID struct { StakerID idx.ValidatorID Staker *SfcStaker }
SfcStakerAndID is pair SfcStaker + StakerID
type Store ¶
Store is a node persistent storage working over physical key-value database.
func (*Store) DelSfcDelegation ¶
func (s *Store) DelSfcDelegation(id DelegationID)
DelSfcDelegation deletes SfcDelegation
func (*Store) DelSfcStaker ¶
func (s *Store) DelSfcStaker(stakerID idx.ValidatorID)
DelSfcStaker deletes SfcStaker
func (*Store) ForEachSfcDelegation ¶
func (s *Store) ForEachSfcDelegation(do func(SfcDelegationAndID))
ForEachSfcDelegation iterates all stored SfcDelegations
func (*Store) ForEachSfcStaker ¶
func (s *Store) ForEachSfcStaker(do func(SfcStakerAndID))
ForEachSfcStaker iterates all stored SfcStakers
func (*Store) GetDelegationClaimedRewards ¶
func (s *Store) GetDelegationClaimedRewards(id DelegationID) *big.Int
GetDelegationClaimedRewards returns sum of claimed rewards in past, by this delegation
func (*Store) GetEpochValidators ¶
func (s *Store) GetEpochValidators(epoch idx.Epoch) []SfcStakerAndID
GetEpochValidators returns all stored EpochValidators on the epoch
func (*Store) GetSfcDelegation ¶
func (s *Store) GetSfcDelegation(id DelegationID) *SfcDelegation
GetSfcDelegation returns stored SfcDelegation
func (*Store) GetSfcDelegationsByAddr ¶
func (s *Store) GetSfcDelegationsByAddr(addr common.Address, limit int) []SfcDelegationAndID
GetSfcDelegationsByAddr returns a lsit of delegations by address
func (*Store) GetSfcStaker ¶
func (s *Store) GetSfcStaker(stakerID idx.ValidatorID) *SfcStaker
GetSfcStaker returns stored SfcStaker
func (*Store) GetSfcStakers ¶
func (s *Store) GetSfcStakers() []SfcStakerAndID
GetSfcStakers returns all stored SfcStakers
func (*Store) GetStakerDelegationsClaimedRewards ¶
func (s *Store) GetStakerDelegationsClaimedRewards(stakerID idx.ValidatorID) *big.Int
GetStakerDelegationsClaimedRewards returns sum of claimed rewards in past, by this delegations of this staker
func (*Store) HasEpochValidator ¶
HasEpochValidator returns true if validator exists
func (*Store) HasSfcStaker ¶
func (s *Store) HasSfcStaker(stakerID idx.ValidatorID) bool
HasSfcStaker returns true if staker exists
func (*Store) IncDelegationClaimedRewards ¶
func (s *Store) IncDelegationClaimedRewards(id DelegationID, diff *big.Int)
IncDelegationClaimedRewards increments sum of claimed rewards in past
func (*Store) IncStakerDelegationsClaimedRewards ¶
func (s *Store) IncStakerDelegationsClaimedRewards(stakerID idx.ValidatorID, diff *big.Int)
IncStakerDelegationsClaimedRewards increments sum of claimed rewards in past
func (*Store) SetDelegationClaimedRewards ¶
func (s *Store) SetDelegationClaimedRewards(id DelegationID, amount *big.Int)
SetDelegationClaimedRewards sets sum of claimed rewards in past
func (*Store) SetEpochValidators ¶
func (s *Store) SetEpochValidators(epoch idx.Epoch, vv []SfcStakerAndID)
SetEpochValidators stores EpochValidators
func (*Store) SetSfcDelegation ¶
func (s *Store) SetSfcDelegation(id DelegationID, v *SfcDelegation)
SetSfcDelegation stores SfcDelegation
func (*Store) SetSfcStaker ¶
func (s *Store) SetSfcStaker(stakerID idx.ValidatorID, v *SfcStaker)
SetSfcStaker stores SfcStaker
func (*Store) SetStakerDelegationsClaimedRewards ¶
func (s *Store) SetStakerDelegationsClaimedRewards(stakerID idx.ValidatorID, amount *big.Int)
SetStakerDelegationsClaimedRewards sets sum of claimed rewards in past