state

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: LGPL-3.0 Imports: 33 Imported by: 12

Documentation

Index

Constants

View Source
const (
	Undefined IdentityState = 0
	Invite    IdentityState = 1
	Candidate IdentityState = 2
	Verified  IdentityState = 3
	Suspended IdentityState = 4
	Killed    IdentityState = 5
	Zombie    IdentityState = 6
	Newbie    IdentityState = 7
	Human     IdentityState = 8

	MaxInvitesAmount    = math.MaxUint8
	EmptyBlocksBitsSize = 25

	AdditionalVerifiedFlips = 1
	AdditionalHumanFlips    = 2

	// Minimal number of blocks in after long period which should be without ceremonial txs
	AfterLongRequiredBlocks = 5
)
View Source
const (
	MaxSavedStatesCount = 100
	GeneticCodeSize     = 12
)
View Source
const (
	SnapshotBlockSize = 10000
)
View Source
const SnapshotVersionV2 = SnapshotVersion(2)
View Source
const (
	SnapshotsFolder = "/snapshots"
)

Variables

View Source
var (
	StateDbKeys         = &stateDbKeys{}
	IdentityStateDbKeys = &identityStateDbPrefix{}
)
View Source
var (
	InvalidManifestPrefix = []byte("im")
	MaxManifestTimeouts   = byte(5)
)

Functions

func IsCeremonyCandidate

func IsCeremonyCandidate(identity Identity) bool

func IsCeremonyCandidateData added in v0.28.5

func IsCeremonyCandidateData(state IdentityState, hasDoneAllRequiredFlips bool) bool

func ReadTreeFrom2 added in v0.26.7

func ReadTreeFrom2(pdb *dbm.PrefixDB, height uint64, root common.Hash, from io.Reader) error

func WriteTreeTo2 added in v0.26.7

func WriteTreeTo2(sourceDb dbm.DB, height uint64, to io.Writer) (common.Hash, error)

Types

type Account

type Account struct {
	Nonce    uint32
	Epoch    uint16
	Balance  *big.Int
	Contract *ContractData
}

Account is the Idena consensus representation of accounts. These objects are stored in the main account trie.

func (*Account) FromBytes added in v0.21.0

func (a *Account) FromBytes(data []byte) error

func (*Account) ToBytes added in v0.21.0

func (a *Account) ToBytes() ([]byte, error)

type ApprovedIdentity

type ApprovedIdentity struct {
	Validated     bool
	Online        bool
	Discriminated bool
	Delegatee     *common.Address
}

func (*ApprovedIdentity) FromBytes added in v0.21.0

func (s *ApprovedIdentity) FromBytes(data []byte) error

func (*ApprovedIdentity) ToBytes added in v0.21.0

func (s *ApprovedIdentity) ToBytes(enableUpgrade8 bool) ([]byte, error)

type ApprovedIdentityFlag added in v0.29.0

type ApprovedIdentityFlag uint32
const (
	Validated ApprovedIdentityFlag = 1 << iota
	Online
	Discriminated
)

func (ApprovedIdentityFlag) HasFlag added in v0.29.0

type BitArray

type BitArray struct {
	Bits  uint     `json:"bits"`  // NOTE: persisted via reflect, must be exported
	Elems []uint64 `json:"elems"` // NOTE: persisted via reflect, must be exported
	// contains filtered or unexported fields
}

BitArray is a thread-safe implementation of a bit array.

func NewBitArray

func NewBitArray(bits int) *BitArray

NewBitArray returns a new bit array. It returns nil if the number of bits is zero.

func (*BitArray) Bytes

func (bA *BitArray) Bytes() []byte

Bytes returns the byte representation of the bits within the bitarray.

func (*BitArray) GetIndex

func (bA *BitArray) GetIndex(i int) bool

GetIndex returns the bit at index i within the bit array. The behavior is undefined if i >= bA.Bits

func (*BitArray) MarshalJSON

func (bA *BitArray) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface by marshaling bit array using a custom format: a string of '-' or 'x' where 'x' denotes the 1 bit.

func (*BitArray) SetIndex

func (bA *BitArray) SetIndex(i int, v bool) bool

SetIndex sets the bit at index i within the bit array. The behavior is undefined if i >= bA.Bits

func (*BitArray) Size

func (bA *BitArray) Size() uint

Size returns the number of bits in the bitarray

func (*BitArray) String

func (bA *BitArray) String() string

String returns a string representation of BitArray: BA{<bit-string>}, where <bit-string> is a sequence of 'x' (1) and '_' (0). The <bit-string> includes spaces and newlines to help people. For a simple sequence of 'x' and '_' characters with no spaces or newlines, see the MarshalJSON() method. Example: "BA{_x_}" or "nil-BitArray" for nil.

func (*BitArray) StringIndented

func (bA *BitArray) StringIndented(indent string) string

StringIndented returns the same thing as String(), but applies the indent at every 10th bit, and twice at every 50th bit.

func (*BitArray) UnmarshalJSON

func (bA *BitArray) UnmarshalJSON(bz []byte) error

UnmarshalJSON implements json.Unmarshaler interface by unmarshaling a custom JSON description.

type ContractData added in v0.22.0

type ContractData struct {
	CodeHash common.Hash
	Stake    *big.Int
}

type DelayedPenalties added in v0.25.3

type DelayedPenalties struct {
	Identities []common.Address
}

func (*DelayedPenalties) FromBytes added in v0.25.3

func (dp *DelayedPenalties) FromBytes(data []byte) error

func (*DelayedPenalties) ToBytes added in v0.25.3

func (dp *DelayedPenalties) ToBytes() ([]byte, error)

type Delegation added in v0.25.0

type Delegation struct {
	Delegator common.Address
	Delegatee common.Address
}

type DelegationSwitch added in v0.25.0

type DelegationSwitch struct {
	Delegations []*Delegation
}

func (*DelegationSwitch) FromBytes added in v0.25.0

func (s *DelegationSwitch) FromBytes(data []byte) error

func (*DelegationSwitch) ToBytes added in v0.25.0

func (s *DelegationSwitch) ToBytes() ([]byte, error)

type Global

type Global struct {
	Epoch                         uint16
	NextValidationTime            int64
	ValidationPeriod              ValidationPeriod
	GodAddress                    common.Address
	WordsSeed                     types.Seed
	LastSnapshot                  uint64
	EpochBlock                    uint64
	PrevEpochBlocks               []uint64
	FeePerGas                     *big.Int
	VrfProposerThreshold          uint64
	EmptyBlocksBits               *big.Int
	GodAddressInvites             uint16
	BlocksCntWithoutCeremonialTxs uint32
	ShardsNum                     uint32
	EmptyBlocksByShards           map[common.ShardId][]common.Address
	ShardSizes                    map[common.ShardId]uint32
}

func (*Global) FromBytes added in v0.21.0

func (s *Global) FromBytes(data []byte) error

func (*Global) ToBytes added in v0.21.0

func (s *Global) ToBytes() ([]byte, error)

type Identity

type Identity struct {
	ProfileHash    []byte
	Stake          *big.Int
	Invites        uint8
	Birthday       uint16
	State          IdentityState
	QualifiedFlips uint32
	// should use GetShortFlipPoints instead of reading directly
	ShortFlipPoints      uint32
	PubKey               []byte
	RequiredFlips        uint8
	Flips                []IdentityFlip
	Generation           uint32
	Code                 []byte
	Invitees             []TxAddr
	Inviter              *Inviter
	Penalty              *big.Int
	ValidationTxsBits    byte
	LastValidationStatus ValidationStatusFlag
	Scores               []byte

	DelegationNonce uint32
	DelegationEpoch uint16

	// do not use directly
	ShardId common.ShardId
	// contains filtered or unexported fields
}

func (*Identity) Delegatee added in v0.25.0

func (i *Identity) Delegatee() *common.Address

func (*Identity) FromBytes added in v0.21.0

func (i *Identity) FromBytes(data []byte) error

func (*Identity) GetMaximumAvailableFlips

func (i *Identity) GetMaximumAvailableFlips() uint8

func (*Identity) GetShortFlipPoints

func (i *Identity) GetShortFlipPoints() float32

func (*Identity) GetTotalWordPairsCount

func (i *Identity) GetTotalWordPairsCount() int

func (*Identity) HasDoneAllRequiredFlips

func (i *Identity) HasDoneAllRequiredFlips() bool

func (*Identity) HasValidationTx added in v0.29.0

func (i *Identity) HasValidationTx(txType types.TxType) bool

func (*Identity) IsDiscriminated added in v0.29.0

func (i *Identity) IsDiscriminated(epoch uint16) bool

func (*Identity) Metadata added in v0.30.0

func (i *Identity) Metadata() interface{}

func (*Identity) PenaltySeconds added in v0.30.0

func (i *Identity) PenaltySeconds() uint16

func (*Identity) PenaltyTimestamp added in v0.30.0

func (i *Identity) PenaltyTimestamp() int64

func (*Identity) PendingUndelegation added in v0.29.0

func (i *Identity) PendingUndelegation() *common.Address

func (*Identity) ReplenishedStake added in v0.29.0

func (i *Identity) ReplenishedStake() *big.Int

func (*Identity) SetPenaltySeconds added in v0.30.0

func (i *Identity) SetPenaltySeconds(penaltySeconds uint16)

func (*Identity) SetPenaltyTimestamp added in v0.30.0

func (i *Identity) SetPenaltyTimestamp(penaltyTimestamp int64)

func (*Identity) ShiftedShardId added in v0.27.0

func (i *Identity) ShiftedShardId() common.ShardId

func (*Identity) ToBytes added in v0.21.0

func (i *Identity) ToBytes() ([]byte, error)

type IdentityFlip

type IdentityFlip struct {
	Cid  []byte
	Pair uint8
}

type IdentityState

type IdentityState uint8

func (IdentityState) IsInShard added in v0.27.0

func (s IdentityState) IsInShard() bool

func (IdentityState) NewbieOrBetter

func (s IdentityState) NewbieOrBetter() bool

func (IdentityState) VerifiedOrBetter

func (s IdentityState) VerifiedOrBetter() bool

type IdentityStateDB

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

func NewLazyIdentityState

func NewLazyIdentityState(db dbm.DB) (*IdentityStateDB, error)

func (*IdentityStateDB) AddDiff

func (s *IdentityStateDB) AddDiff(height uint64, diff *IdentityStateDiff)

func (*IdentityStateDB) Clear

func (s *IdentityStateDB) Clear()

func (*IdentityStateDB) Commit

func (s *IdentityStateDB) Commit(deleteEmptyObjects, enableUpgrade8 bool) (root []byte, version int64, diff *IdentityStateDiff, err error)

Commit writes the state to the underlying in-memory trie database.

func (*IdentityStateDB) CommitSnapshot added in v0.23.0

func (s *IdentityStateDB) CommitSnapshot(height uint64) (dropDb dbm.DB)

func (*IdentityStateDB) CommitTree

func (s *IdentityStateDB) CommitTree(newVersion int64) (root []byte, version int64, err error)

func (*IdentityStateDB) CreatePreliminaryCopy

func (s *IdentityStateDB) CreatePreliminaryCopy(height uint64) (*IdentityStateDB, error)

func (*IdentityStateDB) Delegatee added in v0.25.0

func (s *IdentityStateDB) Delegatee(addr common.Address) *common.Address

func (*IdentityStateDB) DropPreliminary

func (s *IdentityStateDB) DropPreliminary()

func (*IdentityStateDB) ForCheck

func (s *IdentityStateDB) ForCheck(height uint64) (*IdentityStateDB, error)

func (*IdentityStateDB) ForCheckWithOverwrite added in v0.19.3

func (s *IdentityStateDB) ForCheckWithOverwrite(height uint64) (*IdentityStateDB, error)

func (*IdentityStateDB) GetOrNewIdentityObject

func (s *IdentityStateDB) GetOrNewIdentityObject(addr common.Address) *stateApprovedIdentity

Retrieve a state object or create a new state object if nil

func (*IdentityStateDB) HasVersion

func (s *IdentityStateDB) HasVersion(height uint64) bool

func (*IdentityStateDB) IsOnline

func (s *IdentityStateDB) IsOnline(addr common.Address) bool

func (*IdentityStateDB) IsValidated added in v0.29.0

func (s *IdentityStateDB) IsValidated(addr common.Address) bool

func (*IdentityStateDB) IterateIdentities

func (s *IdentityStateDB) IterateIdentities(fn func(key []byte, value []byte) bool) bool

func (*IdentityStateDB) Load

func (s *IdentityStateDB) Load(height uint64) error

func (*IdentityStateDB) LoadPreliminary

func (s *IdentityStateDB) LoadPreliminary(height uint64) (*IdentityStateDB, error)

func (*IdentityStateDB) MarkStateIdentityObjectDirty

func (s *IdentityStateDB) MarkStateIdentityObjectDirty(addr common.Address)

MarkStateAccountObjectDirty adds the specified object to the dirty map to avoid costly state object cache iteration to find a handful of modified ones.

func (*IdentityStateDB) Precommit

func (s *IdentityStateDB) Precommit(deleteEmptyObjects bool, enableUpgrade8 bool) *IdentityStateDiff

func (*IdentityStateDB) Readonly

func (s *IdentityStateDB) Readonly(height uint64) (*IdentityStateDB, error)

func (*IdentityStateDB) RecoverSnapshot2 added in v0.27.3

func (s *IdentityStateDB) RecoverSnapshot2(height uint64, treeRoot common.Hash, from io.Reader) error

func (*IdentityStateDB) Remove

func (s *IdentityStateDB) Remove(identity common.Address)

func (*IdentityStateDB) RemoveDelegatee added in v0.25.0

func (s *IdentityStateDB) RemoveDelegatee(addr common.Address)

func (*IdentityStateDB) Reset

func (s *IdentityStateDB) Reset()

func (*IdentityStateDB) ResetTo

func (s *IdentityStateDB) ResetTo(height uint64) error

func (*IdentityStateDB) Root

func (s *IdentityStateDB) Root() common.Hash

func (*IdentityStateDB) SaveForcedVersion

func (s *IdentityStateDB) SaveForcedVersion(height uint64) error

func (*IdentityStateDB) SetDelegatee added in v0.25.0

func (s *IdentityStateDB) SetDelegatee(addr common.Address, delegatee common.Address)

func (*IdentityStateDB) SetDiscriminated added in v0.29.0

func (s *IdentityStateDB) SetDiscriminated(identity common.Address, discriminated bool)

func (*IdentityStateDB) SetOnline

func (s *IdentityStateDB) SetOnline(addr common.Address, online bool)

func (*IdentityStateDB) SetPredefinedIdentities

func (s *IdentityStateDB) SetPredefinedIdentities(state *models.ProtoPredefinedState)

func (*IdentityStateDB) SetValidated added in v0.29.0

func (s *IdentityStateDB) SetValidated(identity common.Address, validated bool)

func (*IdentityStateDB) SwitchToPreliminary

func (s *IdentityStateDB) SwitchToPreliminary(height uint64) (batch dbm.Batch, dropDb dbm.DB, err error)

func (*IdentityStateDB) Version

func (s *IdentityStateDB) Version() uint64

type IdentityStateDiff

type IdentityStateDiff struct {
	Values []*IdentityStateDiffValue
}

func (*IdentityStateDiff) Empty

func (diff *IdentityStateDiff) Empty() bool

func (*IdentityStateDiff) FromBytes added in v0.21.0

func (diff *IdentityStateDiff) FromBytes(data []byte) error

func (*IdentityStateDiff) FromProto added in v0.21.0

func (*IdentityStateDiff) ToBytes added in v0.21.0

func (diff *IdentityStateDiff) ToBytes() ([]byte, error)

func (*IdentityStateDiff) ToProto added in v0.21.0

type IdentityStateDiffValue

type IdentityStateDiffValue struct {
	Address common.Address
	Deleted bool
	Value   []byte
}

type IdentityStatusSwitch

type IdentityStatusSwitch struct {
	Addresses []common.Address
}

func (*IdentityStatusSwitch) FromBytes added in v0.21.0

func (s *IdentityStatusSwitch) FromBytes(data []byte) error

func (*IdentityStatusSwitch) ToBytes added in v0.21.0

func (s *IdentityStatusSwitch) ToBytes() ([]byte, error)

type IdentityUpdateHook added in v0.30.0

type IdentityUpdateHook = func(identity *Identity)

type ImmutableTree

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

func (*ImmutableTree) AvailableVersions

func (t *ImmutableTree) AvailableVersions() []int

func (*ImmutableTree) DeleteVersion

func (t *ImmutableTree) DeleteVersion(version int64) error

func (*ImmutableTree) ExistVersion

func (t *ImmutableTree) ExistVersion(version int64) bool

func (*ImmutableTree) Exporter added in v0.26.7

func (t *ImmutableTree) Exporter() *iavl.Exporter

func (*ImmutableTree) Get

func (t *ImmutableTree) Get(key []byte) (index int64, value []byte)

func (*ImmutableTree) GetImmutable

func (t *ImmutableTree) GetImmutable() *ImmutableTree

func (*ImmutableTree) GetWithProof added in v0.28.3

func (t *ImmutableTree) GetWithProof(key []byte) ([]byte, error)

func (*ImmutableTree) Hash

func (t *ImmutableTree) Hash() common.Hash

func (*ImmutableTree) Iterate

func (t *ImmutableTree) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)

Iterate iterates over all keys of the tree, in order.

func (*ImmutableTree) IterateRange

func (t *ImmutableTree) IterateRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) (stopped bool)

IterateRange makes a callback for all nodes with key between start and end non-inclusive. If either are nil, then it is open on that side (nil, nil is the same as Iterate)

func (*ImmutableTree) IterateRangeInclusive

func (t *ImmutableTree) IterateRangeInclusive(start, end []byte, ascending bool, fn func(key, value []byte, version int64) bool) (stopped bool)

IterateRangeInclusive makes a callback for all nodes with key between start and end inclusive. If either are nil, then it is open on that side (nil, nil is the same as Iterate)

func (*ImmutableTree) Load

func (t *ImmutableTree) Load() (int64, error)

func (*ImmutableTree) LoadVersion

func (t *ImmutableTree) LoadVersion(targetVersion int64) (int64, error)

func (*ImmutableTree) LoadVersionForOverwriting

func (t *ImmutableTree) LoadVersionForOverwriting(targetVersion int64) (int64, error)

func (*ImmutableTree) Remove

func (t *ImmutableTree) Remove(key []byte) ([]byte, bool)

func (*ImmutableTree) Rollback

func (t *ImmutableTree) Rollback()

func (*ImmutableTree) SaveVersion

func (t *ImmutableTree) SaveVersion() ([]byte, int64, error)

func (*ImmutableTree) SaveVersionAt

func (t *ImmutableTree) SaveVersionAt(version int64) ([]byte, int64, error)

func (*ImmutableTree) Set

func (t *ImmutableTree) Set(key, value []byte) bool

func (*ImmutableTree) SetVirtualVersion

func (t *ImmutableTree) SetVirtualVersion(version int64)

func (*ImmutableTree) ValidateTree

func (t *ImmutableTree) ValidateTree() bool

func (*ImmutableTree) Version

func (t *ImmutableTree) Version() int64

func (*ImmutableTree) WorkingHash

func (t *ImmutableTree) WorkingHash() common.Hash

type Inviter added in v0.25.3

type Inviter struct {
	TxHash      common.Hash
	Address     common.Address
	EpochHeight uint32
}

type MutableTree

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

func NewMutableTree

func NewMutableTree(db dbm.DB) *MutableTree

func (*MutableTree) AvailableVersions

func (t *MutableTree) AvailableVersions() []int

func (*MutableTree) DeleteVersion

func (t *MutableTree) DeleteVersion(version int64) error

func (*MutableTree) ExistVersion

func (t *MutableTree) ExistVersion(version int64) bool

func (*MutableTree) Get

func (t *MutableTree) Get(key []byte) (index int64, value []byte)

func (*MutableTree) GetImmutable

func (t *MutableTree) GetImmutable() *ImmutableTree

func (*MutableTree) Hash

func (t *MutableTree) Hash() common.Hash

func (*MutableTree) Importer added in v0.26.7

func (t *MutableTree) Importer(version int64) (*iavl.Importer, error)

func (*MutableTree) LazyLoad added in v0.19.3

func (t *MutableTree) LazyLoad(version int64) (int64, error)

func (*MutableTree) Load

func (t *MutableTree) Load() (int64, error)

func (*MutableTree) LoadVersion

func (t *MutableTree) LoadVersion(targetVersion int64) (int64, error)

func (*MutableTree) LoadVersionForOverwriting

func (t *MutableTree) LoadVersionForOverwriting(targetVersion int64) (int64, error)

func (*MutableTree) Remove

func (t *MutableTree) Remove(key []byte) ([]byte, bool)

func (*MutableTree) Rollback

func (t *MutableTree) Rollback()

func (*MutableTree) SaveVersion

func (t *MutableTree) SaveVersion() ([]byte, int64, error)

func (*MutableTree) SaveVersionAt

func (t *MutableTree) SaveVersionAt(version int64) ([]byte, int64, error)

func (*MutableTree) Set

func (t *MutableTree) Set(key, value []byte) bool

func (*MutableTree) SetVirtualVersion

func (t *MutableTree) SetVirtualVersion(version int64)

func (*MutableTree) ValidateTree

func (t *MutableTree) ValidateTree() bool

func (*MutableTree) Version

func (t *MutableTree) Version() int64

func (*MutableTree) WorkingHash

func (t *MutableTree) WorkingHash() common.Hash

type NonceCache

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

func NewNonceCache

func NewNonceCache(sdb *StateDB) (*NonceCache, error)

func (*NonceCache) Clear added in v0.19.3

func (ns *NonceCache) Clear()

func (*NonceCache) GetNonce

func (ns *NonceCache) GetNonce(addr common.Address, epoch uint16) uint32

GetNonce returns the canonical nonce for the managed or unmanaged account. Because GetNonce mutates the DB, we must take a write lock.

func (*NonceCache) Lock added in v0.19.3

func (ns *NonceCache) Lock()

func (*NonceCache) ReloadFallback added in v0.19.3

func (ns *NonceCache) ReloadFallback(sdb *StateDB) error

func (*NonceCache) SetNonce

func (ns *NonceCache) SetNonce(addr common.Address, txEpoch uint16, nonce uint32)

SetNonce sets the new canonical nonce for the managed state

func (*NonceCache) UnLock added in v0.19.3

func (ns *NonceCache) UnLock()

func (*NonceCache) UnsafeSetNonce added in v0.19.3

func (ns *NonceCache) UnsafeSetNonce(addr common.Address, txEpoch uint16, nonce uint32)

type SnapshotManager

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

func NewSnapshotManager

func NewSnapshotManager(db dbm.DB, state *StateDB, bus eventbus.Bus, ipfs ipfs.Proxy, cfg *config.Config) *SnapshotManager

func (*SnapshotManager) AddInvalidManifest

func (m *SnapshotManager) AddInvalidManifest(cid []byte)

func (*SnapshotManager) AddTimeoutManifest

func (m *SnapshotManager) AddTimeoutManifest(cid []byte)

func (*SnapshotManager) DownloadSnapshot

func (m *SnapshotManager) DownloadSnapshot(snapshot *snapshot.Manifest) (filePath string, version SnapshotVersion, err error)

func (*SnapshotManager) IsInvalidManifest

func (m *SnapshotManager) IsInvalidManifest(cid []byte) bool

func (*SnapshotManager) StartSync

func (m *SnapshotManager) StartSync()

func (*SnapshotManager) StopSync

func (m *SnapshotManager) StopSync()

type SnapshotVersion added in v0.26.7

type SnapshotVersion byte

type StateDB

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

func NewLazy

func NewLazy(db dbm.DB) (*StateDB, error)

func (*StateDB) AccountExists

func (s *StateDB) AccountExists(address common.Address) bool

func (*StateDB) AddBalance

func (s *StateDB) AddBalance(addr common.Address, amount *big.Int)

AddBalance adds amount to the account associated with addr

func (*StateDB) AddBlockBit

func (s *StateDB) AddBlockBit(empty bool)

func (*StateDB) AddDelayedPenalty added in v0.25.3

func (s *StateDB) AddDelayedPenalty(addr common.Address)

func (*StateDB) AddDiff added in v0.26.3

func (s *StateDB) AddDiff(diffs []*StateTreeDiff)

func (*StateDB) AddEmptyBlockByShard added in v0.27.0

func (s *StateDB) AddEmptyBlockByShard(onlineSize int, shardId common.ShardId, proposer common.Address)

func (*StateDB) AddFlip

func (s *StateDB) AddFlip(addr common.Address, cid []byte, pair uint8)

func (*StateDB) AddInvite

func (s *StateDB) AddInvite(address common.Address, amount uint8)

func (*StateDB) AddInvitee

func (s *StateDB) AddInvitee(address, inviteeAddress common.Address, txHash common.Hash)

func (*StateDB) AddNewScore added in v0.22.0

func (s *StateDB) AddNewScore(address common.Address, score byte, enableUpgrade8 bool)

func (*StateDB) AddPrevEpochBlock added in v0.25.3

func (s *StateDB) AddPrevEpochBlock(height uint64)

func (*StateDB) AddReplenishedStake added in v0.29.0

func (s *StateDB) AddReplenishedStake(address common.Address, intStake *big.Int)

func (*StateDB) AddStake

func (s *StateDB) AddStake(address common.Address, intStake *big.Int)

func (*StateDB) BlocksCntWithoutCeremonialTxs added in v0.21.0

func (s *StateDB) BlocksCntWithoutCeremonialTxs() uint32

func (*StateDB) CanCompleteEpoch added in v0.27.0

func (s *StateDB) CanCompleteEpoch() bool

func (*StateDB) Clear

func (s *StateDB) Clear()

func (*StateDB) ClearAccount added in v0.20.0

func (s *StateDB) ClearAccount(addr common.Address)

func (*StateDB) ClearDelayedOfflinePenalties added in v0.25.3

func (s *StateDB) ClearDelayedOfflinePenalties()

func (*StateDB) ClearDelegations added in v0.25.0

func (s *StateDB) ClearDelegations()

func (*StateDB) ClearEmptyBlocksByShard added in v0.27.0

func (s *StateDB) ClearEmptyBlocksByShard()

func (*StateDB) ClearFlips

func (s *StateDB) ClearFlips(addr common.Address)

func (*StateDB) ClearPenalty

func (s *StateDB) ClearPenalty(address common.Address)

func (*StateDB) ClearStatusSwitchAddresses

func (s *StateDB) ClearStatusSwitchAddresses()

func (*StateDB) CollectKilledDelegators added in v0.25.0

func (s *StateDB) CollectKilledDelegators() []common.Address

func (*StateDB) Commit

func (s *StateDB) Commit(deleteEmptyObjects bool) (diff []*StateTreeDiff, root []byte, version int64, err error)

Commit writes the state to the underlying in-memory trie database.

func (*StateDB) CommitSnapshot

func (s *StateDB) CommitSnapshot(height uint64, batch dbm.Batch) (dropDb dbm.DB)

func (*StateDB) CommitTree

func (s *StateDB) CommitTree(newVersion int64) (root []byte, version int64, err error)

func (*StateDB) DecreaseShardSize added in v0.27.0

func (s *StateDB) DecreaseShardSize(shardId common.ShardId)

func (*StateDB) DelayedOfflinePenalties added in v0.25.3

func (s *StateDB) DelayedOfflinePenalties() []common.Address

func (*StateDB) Delegatee added in v0.25.0

func (s *StateDB) Delegatee(addr common.Address) *common.Address

func (*StateDB) DelegationEpoch added in v0.25.0

func (s *StateDB) DelegationEpoch(addr common.Address) uint16

func (*StateDB) DelegationSwitch added in v0.25.0

func (s *StateDB) DelegationSwitch(sender common.Address) *Delegation

func (*StateDB) Delegations added in v0.25.0

func (s *StateDB) Delegations() []*Delegation

func (*StateDB) DeleteFlip

func (s *StateDB) DeleteFlip(addr common.Address, cid []byte)

func (*StateDB) DeployContract added in v0.22.0

func (s *StateDB) DeployContract(addr common.Address, codeHash common.Hash, stake *big.Int)

func (*StateDB) DropContract added in v0.22.0

func (s *StateDB) DropContract(addr common.Address)

func (*StateDB) DropSnapshot

func (s *StateDB) DropSnapshot(manifest *snapshot.Manifest)

func (*StateDB) EmptyBlocksByShard added in v0.27.0

func (s *StateDB) EmptyBlocksByShard() map[common.ShardId][]common.Address

func (*StateDB) EmptyBlocksCount

func (s *StateDB) EmptyBlocksCount() int

func (*StateDB) Epoch

func (s *StateDB) Epoch() uint16

func (*StateDB) EpochBlock

func (s *StateDB) EpochBlock() uint64

func (*StateDB) FeePerGas added in v0.22.0

func (s *StateDB) FeePerGas() *big.Int

func (*StateDB) FlipWordsSeed

func (s *StateDB) FlipWordsSeed() types.Seed

func (*StateDB) ForCheck

func (s *StateDB) ForCheck(height uint64) (*StateDB, error)

func (*StateDB) ForCheckWithOverwrite added in v0.19.3

func (s *StateDB) ForCheckWithOverwrite(height uint64) (*StateDB, error)

func (*StateDB) GeneticCode

func (s *StateDB) GeneticCode(address common.Address) (generation uint32, code []byte)

func (*StateDB) GetBalance

func (s *StateDB) GetBalance(addr common.Address) *big.Int

Retrieve the balance from the given address or 0 if object not found

func (*StateDB) GetCodeHash added in v0.22.0

func (s *StateDB) GetCodeHash(addr common.Address) *common.Hash

func (*StateDB) GetContractStake added in v0.22.0

func (s *StateDB) GetContractStake(addr common.Address) *big.Int

func (*StateDB) GetContractValue added in v0.22.0

func (s *StateDB) GetContractValue(addr common.Address, key []byte) []byte

func (*StateDB) GetEpoch

func (s *StateDB) GetEpoch(addr common.Address) uint16

func (*StateDB) GetIdentity

func (s *StateDB) GetIdentity(addr common.Address) Identity

func (*StateDB) GetIdentityState

func (s *StateDB) GetIdentityState(addr common.Address) IdentityState

func (*StateDB) GetIdentityWithProof added in v0.28.3

func (s *StateDB) GetIdentityWithProof(addr common.Address) ([]byte, error)

func (*StateDB) GetInvitees

func (s *StateDB) GetInvitees(address common.Address) []TxAddr

func (*StateDB) GetInviter

func (s *StateDB) GetInviter(address common.Address) *Inviter

func (*StateDB) GetInvites

func (s *StateDB) GetInvites(addr common.Address) uint8

func (*StateDB) GetMadeFlips

func (s *StateDB) GetMadeFlips(addr common.Address) uint8

func (*StateDB) GetNonce

func (s *StateDB) GetNonce(addr common.Address) uint32

func (*StateDB) GetOrNewAccountObject

func (s *StateDB) GetOrNewAccountObject(addr common.Address) *stateAccount

Retrieve a state object or create a new state object if nil

func (*StateDB) GetOrNewDelayedOfflinePenaltyObject added in v0.25.3

func (s *StateDB) GetOrNewDelayedOfflinePenaltyObject() *stateDelayedOfflinePenalties

func (*StateDB) GetOrNewDelegationSwitchObject added in v0.25.0

func (s *StateDB) GetOrNewDelegationSwitchObject() *stateDelegationSwitch

func (*StateDB) GetOrNewGlobalObject

func (s *StateDB) GetOrNewGlobalObject() *stateGlobal

Retrieve a state object or create a new state object if nil

func (*StateDB) GetOrNewIdentityObject

func (s *StateDB) GetOrNewIdentityObject(addr common.Address) *stateIdentity

Retrieve a state object or create a new state object if nil

func (*StateDB) GetOrNewStatusSwitchObject

func (s *StateDB) GetOrNewStatusSwitchObject() *stateStatusSwitch

func (*StateDB) GetPenalty

func (s *StateDB) GetPenalty(address common.Address) *big.Int

func (*StateDB) GetPenaltySeconds added in v0.30.0

func (s *StateDB) GetPenaltySeconds(address common.Address) uint16

func (*StateDB) GetPenaltyTimestamp added in v0.30.0

func (s *StateDB) GetPenaltyTimestamp(address common.Address) int64

func (*StateDB) GetProfileHash

func (s *StateDB) GetProfileHash(addr common.Address) []byte

func (*StateDB) GetQualifiedFlipsCount

func (s *StateDB) GetQualifiedFlipsCount(addr common.Address) uint32

func (*StateDB) GetReplenishedStakeBalance added in v0.29.0

func (s *StateDB) GetReplenishedStakeBalance(addr common.Address) *big.Int

func (*StateDB) GetRequiredFlips

func (s *StateDB) GetRequiredFlips(addr common.Address) uint8

func (*StateDB) GetScores added in v0.22.0

func (s *StateDB) GetScores(addr common.Address) []byte

func (*StateDB) GetShortFlipPoints

func (s *StateDB) GetShortFlipPoints(addr common.Address) float32

func (*StateDB) GetStakeBalance

func (s *StateDB) GetStakeBalance(addr common.Address) *big.Int

func (*StateDB) GodAddress

func (s *StateDB) GodAddress() common.Address

func (*StateDB) GodAddressInvites

func (s *StateDB) GodAddressInvites() uint16

func (*StateDB) HasDelayedOfflinePenalty added in v0.25.3

func (s *StateDB) HasDelayedOfflinePenalty(addr common.Address) bool

func (*StateDB) HasStatusSwitchAddresses

func (s *StateDB) HasStatusSwitchAddresses(addr common.Address) bool

func (*StateDB) HasValidationTx

func (s *StateDB) HasValidationTx(addr common.Address, txType types.TxType) bool

func (*StateDB) HasVersion added in v0.26.7

func (s *StateDB) HasVersion(h uint64) bool

func (*StateDB) IncBlocksCntWithoutCeremonialTxs added in v0.21.0

func (s *StateDB) IncBlocksCntWithoutCeremonialTxs()

func (*StateDB) IncEpoch

func (s *StateDB) IncEpoch()

func (*StateDB) IncreaseShardSize added in v0.27.0

func (s *StateDB) IncreaseShardSize(shardId common.ShardId)

func (*StateDB) IsDiscriminated added in v0.29.0

func (s *StateDB) IsDiscriminated(addr common.Address, epoch uint16) bool

func (*StateDB) IterateAccounts

func (s *StateDB) IterateAccounts(fn func(key []byte, value []byte) bool) bool

func (*StateDB) IterateContractStore added in v0.22.0

func (s *StateDB) IterateContractStore(addr common.Address, minKey []byte, maxKey []byte, f func(key []byte, value []byte) bool)

func (*StateDB) IterateContractValues added in v0.22.0

func (s *StateDB) IterateContractValues(f func(key []byte, value []byte) bool)

Iterate over all stored contract data

func (*StateDB) IterateIdentities

func (s *StateDB) IterateIdentities(fn func(key []byte, value []byte) bool) bool

func (*StateDB) IterateOverAccounts added in v0.20.0

func (s *StateDB) IterateOverAccounts(callback func(addr common.Address, account Account))

func (*StateDB) IterateOverIdentities

func (s *StateDB) IterateOverIdentities(callback func(addr common.Address, identity Identity))

func (*StateDB) LastSnapshot

func (s *StateDB) LastSnapshot() uint64

func (*StateDB) Load

func (s *StateDB) Load(height uint64) error

func (*StateDB) MarkStateAccountObjectDirty

func (s *StateDB) MarkStateAccountObjectDirty(addr common.Address)

MarkStateAccountObjectDirty adds the specified object to the dirty map to avoid costly state object cache iteration to find a handful of modified ones.

func (*StateDB) MarkStateDelayedOfflinePenaltyObjectDirty added in v0.25.3

func (s *StateDB) MarkStateDelayedOfflinePenaltyObjectDirty()

func (*StateDB) MarkStateDelegationSwitchObjectDirty added in v0.25.0

func (s *StateDB) MarkStateDelegationSwitchObjectDirty()

func (*StateDB) MarkStateGlobalObjectDirty

func (s *StateDB) MarkStateGlobalObjectDirty()

MarkStateAccountObjectDirty adds the specified object to the dirty map to avoid costly state object cache iteration to find a handful of modified ones.

func (*StateDB) MarkStateIdentityObjectDirty

func (s *StateDB) MarkStateIdentityObjectDirty(addr common.Address)

MarkStateAccountObjectDirty adds the specified object to the dirty map to avoid costly state object cache iteration to find a handful of modified ones.

func (*StateDB) MarkStateStatusSwitchObjectDirty

func (s *StateDB) MarkStateStatusSwitchObjectDirty()

func (*StateDB) NextValidationTime

func (s *StateDB) NextValidationTime() time.Time

func (*StateDB) PendingUndelegation added in v0.29.0

func (s *StateDB) PendingUndelegation(addr common.Address) *common.Address

func (*StateDB) Precommit

func (s *StateDB) Precommit(deleteEmptyObjects bool) []*StateTreeDiff

func (*StateDB) PrevEpochBlocks added in v0.25.3

func (s *StateDB) PrevEpochBlocks() []uint64

func (*StateDB) ProvideIdentityUpdateHook added in v0.30.0

func (s *StateDB) ProvideIdentityUpdateHook(hook IdentityUpdateHook)

func (*StateDB) Readonly

func (s *StateDB) Readonly(height int64) (*StateDB, error)

func (*StateDB) RecoverSnapshot2 added in v0.26.7

func (s *StateDB) RecoverSnapshot2(height uint64, treeRoot common.Hash, from io.Reader) error

func (*StateDB) RemoveContractValue added in v0.22.0

func (s *StateDB) RemoveContractValue(addr common.Address, key []byte)

func (*StateDB) RemoveDelayedOfflinePenalty added in v0.25.3

func (s *StateDB) RemoveDelayedOfflinePenalty(addr common.Address)

func (*StateDB) RemoveDelegatee added in v0.25.0

func (s *StateDB) RemoveDelegatee(addr common.Address)

func (*StateDB) RemoveInvitee

func (s *StateDB) RemoveInvitee(address, inviteeAddress common.Address)

func (*StateDB) RemovePendingUndelegation added in v0.29.0

func (s *StateDB) RemovePendingUndelegation(addr common.Address)

func (*StateDB) Reset

func (s *StateDB) Reset()

func (*StateDB) ResetBlocksCntWithoutCeremonialTxs added in v0.21.0

func (s *StateDB) ResetBlocksCntWithoutCeremonialTxs()

func (*StateDB) ResetEmptyBlockByShard added in v0.27.0

func (s *StateDB) ResetEmptyBlockByShard(shardId common.ShardId)

func (*StateDB) ResetInviter

func (s *StateDB) ResetInviter(address common.Address)

func (*StateDB) ResetTo

func (s *StateDB) ResetTo(height uint64) error

func (*StateDB) ResetValidationTxBits

func (s *StateDB) ResetValidationTxBits(addr common.Address)

func (*StateDB) Root

func (s *StateDB) Root() common.Hash

func (*StateDB) SaveForcedVersion

func (s *StateDB) SaveForcedVersion(height uint64) (root []byte, version int64, err error)

func (*StateDB) SetBalance

func (s *StateDB) SetBalance(addr common.Address, amount *big.Int)

func (*StateDB) SetBirthday

func (s *StateDB) SetBirthday(address common.Address, birthday uint16)

func (*StateDB) SetContractStake added in v0.22.0

func (s *StateDB) SetContractStake(addr common.Address, stake *big.Int)

func (*StateDB) SetContractValue added in v0.22.0

func (s *StateDB) SetContractValue(addr common.Address, key []byte, value []byte)

func (*StateDB) SetDelegatee added in v0.25.0

func (s *StateDB) SetDelegatee(addr common.Address, delegatee common.Address)

func (*StateDB) SetDelegationEpoch added in v0.25.0

func (s *StateDB) SetDelegationEpoch(addr common.Address, epoch uint16)

func (*StateDB) SetDelegationNonce added in v0.25.0

func (s *StateDB) SetDelegationNonce(addr common.Address, nonce uint32)

func (*StateDB) SetEpoch

func (s *StateDB) SetEpoch(addr common.Address, epoch uint16)

func (*StateDB) SetEpochBlock

func (s *StateDB) SetEpochBlock(height uint64)

func (*StateDB) SetFeePerGas added in v0.22.0

func (s *StateDB) SetFeePerGas(fee *big.Int)

func (*StateDB) SetFlipWordsSeed

func (s *StateDB) SetFlipWordsSeed(seed types.Seed)

func (*StateDB) SetGeneticCode

func (s *StateDB) SetGeneticCode(address common.Address, generation uint32, code []byte)

func (*StateDB) SetGlobalEpoch

func (s *StateDB) SetGlobalEpoch(epoch uint16)

func (*StateDB) SetGodAddress

func (s *StateDB) SetGodAddress(godAddress common.Address)

func (*StateDB) SetGodAddressInvites

func (s *StateDB) SetGodAddressInvites(count uint16)

func (*StateDB) SetInviter

func (s *StateDB) SetInviter(address, inviterAddress common.Address, txHash common.Hash, epochHeight uint32)

func (*StateDB) SetInvites

func (s *StateDB) SetInvites(address common.Address, amount uint8)

func (*StateDB) SetLastSnapshot

func (s *StateDB) SetLastSnapshot(height uint64)

func (*StateDB) SetMetadata added in v0.30.0

func (s *StateDB) SetMetadata(address common.Address, metadata interface{})

func (*StateDB) SetNextValidationTime

func (s *StateDB) SetNextValidationTime(t time.Time)

func (*StateDB) SetNonce

func (s *StateDB) SetNonce(addr common.Address, nonce uint32)

func (*StateDB) SetPenalty

func (s *StateDB) SetPenalty(address common.Address, penalty *big.Int, seconds uint16)

func (*StateDB) SetPenaltyTimestamp added in v0.30.0

func (s *StateDB) SetPenaltyTimestamp(address common.Address, timestamp int64)

func (*StateDB) SetPendingUndelegation added in v0.29.0

func (s *StateDB) SetPendingUndelegation(addr common.Address)

func (*StateDB) SetPredefinedAccounts

func (s *StateDB) SetPredefinedAccounts(state *models.ProtoPredefinedState)

func (*StateDB) SetPredefinedContractValues added in v0.22.0

func (s *StateDB) SetPredefinedContractValues(state *models.ProtoPredefinedState)

func (*StateDB) SetPredefinedGlobal

func (s *StateDB) SetPredefinedGlobal(state *models.ProtoPredefinedState)

func (*StateDB) SetPredefinedIdentities

func (s *StateDB) SetPredefinedIdentities(state *models.ProtoPredefinedState)

func (*StateDB) SetPredefinedStatusSwitch

func (s *StateDB) SetPredefinedStatusSwitch(state *models.ProtoPredefinedState)

func (*StateDB) SetProfileHash

func (s *StateDB) SetProfileHash(addr common.Address, hash []byte)

func (*StateDB) SetPubKey

func (s *StateDB) SetPubKey(address common.Address, pubKey []byte)

func (*StateDB) SetRequiredFlips

func (s *StateDB) SetRequiredFlips(addr common.Address, amount uint8)

func (*StateDB) SetShardId added in v0.27.0

func (s *StateDB) SetShardId(addr common.Address, shardId common.ShardId)

func (*StateDB) SetShardSize added in v0.27.0

func (s *StateDB) SetShardSize(shardId common.ShardId, size uint32)

func (*StateDB) SetShardsNum added in v0.27.0

func (s *StateDB) SetShardsNum(num uint32)

func (*StateDB) SetState

func (s *StateDB) SetState(address common.Address, state IdentityState)

func (*StateDB) SetValidationPeriod

func (s *StateDB) SetValidationPeriod(period ValidationPeriod)

func (*StateDB) SetValidationStatus

func (s *StateDB) SetValidationStatus(addr common.Address, status ValidationStatusFlag)

func (*StateDB) SetValidationTxBit

func (s *StateDB) SetValidationTxBit(addr common.Address, txType types.TxType)

func (*StateDB) SetVrfProposerThreshold

func (s *StateDB) SetVrfProposerThreshold(value float64)

func (*StateDB) ShardId added in v0.27.0

func (s *StateDB) ShardId(address common.Address) common.ShardId

func (*StateDB) ShardSizes added in v0.27.0

func (s *StateDB) ShardSizes() map[common.ShardId]uint32

func (*StateDB) ShardsNum added in v0.27.0

func (s *StateDB) ShardsNum() uint32

func (*StateDB) StatusSwitchAddresses

func (s *StateDB) StatusSwitchAddresses() []common.Address

func (*StateDB) SubBalance

func (s *StateDB) SubBalance(addr common.Address, amount *big.Int)

SubBalance subtracts amount from the account associated with addr

func (*StateDB) SubGodAddressInvite

func (s *StateDB) SubGodAddressInvite()

func (*StateDB) SubInvite

func (s *StateDB) SubInvite(address common.Address, amount uint8)

func (*StateDB) SubPenalty

func (s *StateDB) SubPenalty(address common.Address, penalty *big.Int)

func (*StateDB) SubPenaltySeconds added in v0.30.0

func (s *StateDB) SubPenaltySeconds(address common.Address, value uint16)

func (*StateDB) SubReplenishedStake added in v0.29.0

func (s *StateDB) SubReplenishedStake(addr common.Address, amount *big.Int)

func (*StateDB) SubStake

func (s *StateDB) SubStake(addr common.Address, amount *big.Int)

func (*StateDB) ToggleDelegationAddress added in v0.25.0

func (s *StateDB) ToggleDelegationAddress(sender common.Address, delegatee common.Address)

func (*StateDB) ToggleStatusSwitchAddress

func (s *StateDB) ToggleStatusSwitchAddress(sender common.Address)

func (*StateDB) ValidationPeriod

func (s *StateDB) ValidationPeriod() ValidationPeriod

func (*StateDB) Version

func (s *StateDB) Version() int64

func (*StateDB) VrfProposerThreshold

func (s *StateDB) VrfProposerThreshold() float64

func (*StateDB) WriteSnapshot2 added in v0.26.7

func (s *StateDB) WriteSnapshot2(height uint64, to io.Writer) (root common.Hash, err error)

type StateTreeDiff added in v0.26.3

type StateTreeDiff struct {
	Key     []byte
	Value   []byte
	Deleted bool
}

type Tree

type Tree interface {
	Get(key []byte) (index int64, value []byte)
	Set(key, value []byte) bool
	Remove(key []byte) ([]byte, bool)
	LoadVersion(targetVersion int64) (int64, error)
	Load() (int64, error)
	SaveVersion() ([]byte, int64, error)
	DeleteVersion(version int64) error
	GetImmutable() *ImmutableTree
	Version() int64
	Hash() common.Hash
	WorkingHash() common.Hash
	ExistVersion(version int64) bool
	LoadVersionForOverwriting(targetVersion int64) (int64, error)
	Rollback()
	AvailableVersions() []int
	SaveVersionAt(version int64) ([]byte, int64, error)
	SetVirtualVersion(version int64)
	ValidateTree() bool
}

type TxAddr

type TxAddr struct {
	TxHash  common.Hash
	Address common.Address
}

type ValidationPeriod

type ValidationPeriod uint32
const (
	NonePeriod             ValidationPeriod = 0
	FlipLotteryPeriod      ValidationPeriod = 1
	ShortSessionPeriod     ValidationPeriod = 2
	LongSessionPeriod      ValidationPeriod = 3
	AfterLongSessionPeriod ValidationPeriod = 4
)

type ValidationStatusFlag

type ValidationStatusFlag uint16
const (
	AtLeastOneFlipReported ValidationStatusFlag = 1 << iota
	AtLeastOneFlipNotQualified
	AllFlipsNotQualified
)

func (ValidationStatusFlag) HasFlag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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