app

package
v1.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlocksMissed

type BlocksMissed struct {
	Num    idx.Block
	Period inter.Timestamp
}

BlocksMissed is information about missed blocks from a staker

type SfcConstants

type SfcConstants struct {
	ShortGasPowerAllocPerSec uint64
	LongGasPowerAllocPerSec  uint64
	BaseRewardPerSec         *big.Int
	OfflinePenaltyThreshold  BlocksMissed
	MinGasPrice              *big.Int
}

SfcConstants are constants which may be changed by SFC contract

type Store

type Store struct {
	logger.Instance
	// contains filtered or unexported fields
}

Store is a node persistent storage working over physical key-value database.

func NewStore

func NewStore(mainDb kvdb.KeyValueStore, cfg StoreConfig) *Store

NewStore creates store over key-value db.

func (*Store) AddDirtyOriginationScore

func (s *Store) AddDirtyOriginationScore(stakerID idx.StakerID, v *big.Int)

AddDirtyOriginationScore add gas value for active validation score

func (*Store) AddDirtyValidationScore

func (s *Store) AddDirtyValidationScore(stakerID idx.StakerID, v *big.Int)

AddDirtyValidationScore add gas value for active validation score

func (*Store) AddPoiFee

func (s *Store) AddPoiFee(poiPeriod uint64, diff *big.Int)

AddPoiFee add gas used to POI period

func (*Store) ApplyGenesis

func (s *Store) ApplyGenesis(net *lachesis.Config) (evmBlock *evmcore.EvmBlock, err error)

ApplyGenesis writes initial state.

func (*Store) Commit

func (s *Store) Commit() error

Commit changes.

func (*Store) DelActiveOriginationScore

func (s *Store) DelActiveOriginationScore(stakerID idx.StakerID)

DelActiveOriginationScore deletes record about active origination score of a staker

func (*Store) DelActiveValidationScore

func (s *Store) DelActiveValidationScore(stakerID idx.StakerID)

DelActiveValidationScore deletes record about active validation score of a staker

func (*Store) DelAllActiveOriginationScores

func (s *Store) DelAllActiveOriginationScores()

DelAllActiveOriginationScores deletes all the record about dirty origination scores of stakers

func (*Store) DelAllActiveValidationScores

func (s *Store) DelAllActiveValidationScores()

DelAllActiveValidationScores deletes all the record about dirty validation scores of stakers

func (*Store) DelAllWeightedDelegationsFee

func (s *Store) DelAllWeightedDelegationsFee()

DelAllWeightedDelegationsFee deletes all the records about gas used by delegations of all stakers

func (*Store) DelDelegationClaimedRewards

func (s *Store) DelDelegationClaimedRewards(id sfctype.DelegationID)

DelDelegationClaimedRewards deletes record about sum of claimed rewards in past

func (*Store) DelDirtyOriginationScore

func (s *Store) DelDirtyOriginationScore(stakerID idx.StakerID)

DelDirtyOriginationScore deletes record about dirty origination score of a staker

func (*Store) DelDirtyValidationScore

func (s *Store) DelDirtyValidationScore(stakerID idx.StakerID)

DelDirtyValidationScore deletes record about dirty validation score of a staker

func (*Store) DelGasPowerRefunds

func (s *Store) DelGasPowerRefunds(epoch idx.Epoch)

DelGasPowerRefunds erases all record on epoch

func (*Store) DelSfcDelegation

func (s *Store) DelSfcDelegation(id sfctype.DelegationID)

DelSfcDelegation deletes SfcDelegation

func (*Store) DelSfcStaker

func (s *Store) DelSfcStaker(stakerID idx.StakerID)

DelSfcStaker deletes SfcStaker

func (*Store) DelStakerClaimedRewards

func (s *Store) DelStakerClaimedRewards(stakerID idx.StakerID)

DelStakerClaimedRewards deletes record about sum of claimed rewards in past

func (*Store) DelStakerDelegationsClaimedRewards

func (s *Store) DelStakerDelegationsClaimedRewards(stakerID idx.StakerID)

DelStakerDelegationsClaimedRewards deletes record about sum of claimed rewards in past

func (*Store) DelStakerPOI

func (s *Store) DelStakerPOI(stakerID idx.StakerID)

DelStakerPOI deletes record about staker's PoI

func (*Store) DelWeightedDelegationsFee

func (s *Store) DelWeightedDelegationsFee(stakerID idx.StakerID)

DelWeightedDelegationsFee deletes record about gas used by delegations of a staker

func (*Store) EvmLogs

func (s *Store) EvmLogs() *topicsdb.Index

func (*Store) EvmTable

func (s *Store) EvmTable() ethdb.Database

func (*Store) ForEachSfcDelegation

func (s *Store) ForEachSfcDelegation(do func(sfctype.SfcDelegationAndID))

ForEachSfcDelegation iterates all stored SfcDelegations

func (*Store) ForEachSfcStaker

func (s *Store) ForEachSfcStaker(do func(sfctype.SfcStakerAndID))

ForEachSfcStaker iterates all stored SfcStakers

func (*Store) GetActiveOriginationScore

func (s *Store) GetActiveOriginationScore(stakerID idx.StakerID) *big.Int

GetActiveOriginationScore return gas value for active validator score

func (*Store) GetActiveValidationScore

func (s *Store) GetActiveValidationScore(stakerID idx.StakerID) *big.Int

GetActiveValidationScore return gas value for active validator score

func (*Store) GetAddressFee

func (s *Store) GetAddressFee(addr common.Address, poiPeriod uint64) *big.Int

GetAddressFee get gas used by address

func (*Store) GetAddressLastTxTime

func (s *Store) GetAddressLastTxTime(addr common.Address) inter.Timestamp

GetAddressLastTxTime get last time for last tx from this address

func (*Store) GetAddressPOI

func (s *Store) GetAddressPOI(address common.Address) *big.Int

GetAddressPOI get POI value for user address

func (*Store) GetBlocksMissed

func (s *Store) GetBlocksMissed(stakerID idx.StakerID) BlocksMissed

GetBlocksMissed return blocks missed num for validator

func (*Store) GetDelegationClaimedRewards

func (s *Store) GetDelegationClaimedRewards(id sfctype.DelegationID) *big.Int

GetDelegationClaimedRewards returns sum of claimed rewards in past, by this delegation

func (*Store) GetDirtyOriginationScore

func (s *Store) GetDirtyOriginationScore(stakerID idx.StakerID) *big.Int

GetDirtyOriginationScore return gas value for active validator score

func (*Store) GetDirtyValidationScore

func (s *Store) GetDirtyValidationScore(stakerID idx.StakerID) *big.Int

GetDirtyValidationScore return gas value for active validator score

func (*Store) GetEpochValidators

func (s *Store) GetEpochValidators(epoch idx.Epoch) []sfctype.SfcStakerAndID

GetEpochValidators returns all stored EpochValidators on the epoch

func (*Store) GetGasPowerRefund

func (s *Store) GetGasPowerRefund(epoch idx.Epoch, stakerID idx.StakerID) uint64

GetGasPowerRefund returns stored amount of gas power to refund

func (*Store) GetGasPowerRefunds

func (s *Store) GetGasPowerRefunds(epoch idx.Epoch) map[idx.StakerID]uint64

GetGasPowerRefunds returns all stored amount of gas power to refund

func (*Store) GetPoiFee

func (s *Store) GetPoiFee(poiPeriod uint64) *big.Int

GetPoiFee get gas used for POI period

func (*Store) GetReceipts

func (s *Store) GetReceipts(n idx.Block) types.Receipts

GetReceipts returns stored transaction receipts.

func (*Store) GetSfcConstants

func (s *Store) GetSfcConstants(epoch idx.Epoch) SfcConstants

GetSfcConstants returns stored SfcConstants

func (*Store) GetSfcDelegation

func (s *Store) GetSfcDelegation(id sfctype.DelegationID) *sfctype.SfcDelegation

GetSfcDelegation returns stored SfcDelegation

func (*Store) GetSfcDelegationsByAddr

func (s *Store) GetSfcDelegationsByAddr(addr common.Address, limit int) []sfctype.SfcDelegationAndID

GetSfcDelegationsByAddr returns a lsit of delegations by address

func (*Store) GetSfcStaker

func (s *Store) GetSfcStaker(stakerID idx.StakerID) *sfctype.SfcStaker

GetSfcStaker returns stored SfcStaker

func (*Store) GetSfcStakers

func (s *Store) GetSfcStakers() []sfctype.SfcStakerAndID

GetSfcStakers returns all stored SfcStakers

func (*Store) GetStakerClaimedRewards

func (s *Store) GetStakerClaimedRewards(stakerID idx.StakerID) *big.Int

GetStakerClaimedRewards returns sum of claimed rewards in past, by this staker

func (*Store) GetStakerDelegationsClaimedRewards

func (s *Store) GetStakerDelegationsClaimedRewards(stakerID idx.StakerID) *big.Int

GetStakerDelegationsClaimedRewards returns sum of claimed rewards in past, by this delegations of this staker

func (*Store) GetStakerPOI

func (s *Store) GetStakerPOI(stakerID idx.StakerID) *big.Int

GetStakerPOI get POI value for staker

func (*Store) GetTotalSupply

func (s *Store) GetTotalSupply() *big.Int

GetTotalSupply returns total supply

func (*Store) GetWeightedDelegationsFee

func (s *Store) GetWeightedDelegationsFee(stakerID idx.StakerID) *big.Int

GetWeightedDelegationsFee get gas used by delegations of a staker

func (*Store) HasEpochValidator

func (s *Store) HasEpochValidator(epoch idx.Epoch, stakerID idx.StakerID) bool

HasEpochValidator returns true if validator exists

func (*Store) HasSfcConstants

func (s *Store) HasSfcConstants(epoch idx.Epoch) bool

HasSfcConstants returns true if SFC constants are stored

func (*Store) HasSfcStaker

func (s *Store) HasSfcStaker(stakerID idx.StakerID) bool

HasSfcStaker returns true if staker exists

func (*Store) IncBlocksMissed

func (s *Store) IncBlocksMissed(stakerID idx.StakerID, periodDiff inter.Timestamp)

IncBlocksMissed add count of missed blocks for validator

func (*Store) IncDelegationClaimedRewards

func (s *Store) IncDelegationClaimedRewards(id sfctype.DelegationID, diff *big.Int)

IncDelegationClaimedRewards increments sum of claimed rewards in past

func (*Store) IncGasPowerRefund

func (s *Store) IncGasPowerRefund(epoch idx.Epoch, stakerID idx.StakerID, diff uint64)

IncGasPowerRefund increments amount of gas power to refund

func (*Store) IncStakerClaimedRewards

func (s *Store) IncStakerClaimedRewards(stakerID idx.StakerID, diff *big.Int)

IncStakerClaimedRewards increments sum of claimed rewards in past

func (*Store) IncStakerDelegationsClaimedRewards

func (s *Store) IncStakerDelegationsClaimedRewards(stakerID idx.StakerID, diff *big.Int)

IncStakerDelegationsClaimedRewards increments sum of claimed rewards in past

func (*Store) IndexLogs

func (s *Store) IndexLogs(recs ...*types.Log)

StateDB returns state database.

func (*Store) MigrateAdjustableMinGasPrice

func (s *Store) MigrateAdjustableMinGasPrice() error

func (*Store) MigrateAdjustableOfflinePeriod

func (s *Store) MigrateAdjustableOfflinePeriod() error

func (*Store) MigrateEraseGenesisField

func (s *Store) MigrateEraseGenesisField() error

func (*Store) MigrateMultiDelegations

func (s *Store) MigrateMultiDelegations() error

func (*Store) MoveDirtyOriginationScoresToActive

func (s *Store) MoveDirtyOriginationScoresToActive()

MoveDirtyOriginationScoresToActive moves all the dirty records to active

func (*Store) MoveDirtyValidationScoresToActive

func (s *Store) MoveDirtyValidationScoresToActive()

MoveDirtyValidationScoresToActive moves all the dirty records to active

func (*Store) ResetBlocksMissed

func (s *Store) ResetBlocksMissed(stakerID idx.StakerID)

ResetBlocksMissed set to 0 missed blocks for validator

func (*Store) SetAddressFee

func (s *Store) SetAddressFee(addr common.Address, poiPeriod uint64, val *big.Int)

SetAddressFee save gas used by address

func (*Store) SetAddressLastTxTime

func (s *Store) SetAddressLastTxTime(addr common.Address, t inter.Timestamp)

SetAddressLastTxTime save last time for tx from this address

func (*Store) SetAddressPOI

func (s *Store) SetAddressPOI(address common.Address, poi *big.Int)

SetAddressPOI save POI value for a user address

func (*Store) SetDelegationClaimedRewards

func (s *Store) SetDelegationClaimedRewards(id sfctype.DelegationID, amount *big.Int)

SetDelegationClaimedRewards sets sum of claimed rewards in past

func (*Store) SetEpochValidators

func (s *Store) SetEpochValidators(epoch idx.Epoch, vv []sfctype.SfcStakerAndID)

SetEpochValidator stores EpochValidator

func (*Store) SetGasPowerRefund

func (s *Store) SetGasPowerRefund(epoch idx.Epoch, stakerID idx.StakerID, refund uint64)

SetGasPowerRefund stores amount of gas power to refund

func (*Store) SetPoiFee

func (s *Store) SetPoiFee(poiPeriod uint64, val *big.Int)

SetPoiFee save gas used for POI period

func (*Store) SetReceipts

func (s *Store) SetReceipts(n idx.Block, receipts types.Receipts)

SetReceipts stores transaction receipts.

func (*Store) SetSfcConstants

func (s *Store) SetSfcConstants(epoch idx.Epoch, constants SfcConstants)

SetSfcConstants stores SfcConstants

func (*Store) SetSfcDelegation

func (s *Store) SetSfcDelegation(id sfctype.DelegationID, v *sfctype.SfcDelegation)

SetSfcDelegation stores SfcDelegation

func (*Store) SetSfcStaker

func (s *Store) SetSfcStaker(stakerID idx.StakerID, v *sfctype.SfcStaker)

SetSfcStaker stores SfcStaker

func (*Store) SetStakerClaimedRewards

func (s *Store) SetStakerClaimedRewards(stakerID idx.StakerID, amount *big.Int)

SetStakerClaimedRewards sets sum of claimed rewards in past

func (*Store) SetStakerDelegationsClaimedRewards

func (s *Store) SetStakerDelegationsClaimedRewards(stakerID idx.StakerID, amount *big.Int)

SetStakerDelegationsClaimedRewards sets sum of claimed rewards in past

func (*Store) SetStakerPOI

func (s *Store) SetStakerPOI(stakerID idx.StakerID, poi *big.Int)

SetStakerPOI save POI value for staker

func (*Store) SetTotalSupply

func (s *Store) SetTotalSupply(amount *big.Int)

SetTotalSupply stores total supply

func (*Store) SetWeightedDelegationsFee

func (s *Store) SetWeightedDelegationsFee(stakerID idx.StakerID, val *big.Int)

SetWeightedDelegationsFee stores gas used by delegations of a staker

func (*Store) StateDB

func (s *Store) StateDB(from common.Hash) (*state.StateDB, error)

StateDB returns state database.

type StoreConfig

type StoreConfig struct {
	// Cache size for Receipts.
	ReceiptsCacheSize int
	// Cache size for Stakers.
	StakersCacheSize int
	// Cache size for Delegations.
	DelegationsCacheSize int
}

StoreConfig is a config for store db.

func DefaultStoreConfig

func DefaultStoreConfig() StoreConfig

DefaultStoreConfig for product.

func LiteStoreConfig

func LiteStoreConfig() StoreConfig

LiteStoreConfig is for tests or inmemory.

Jump to

Keyboard shortcuts

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