delegatestate

package
v0.0.0-...-d85cb20 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// Accessing tries:
	// OpenTrie opens the main account trie.
	// OpenStorageTrie opens the storage trie of an account.
	OpenTrie(root common.Hash) (Trie, error)
	OpenStorageTrie(addrHash, root common.Hash) (Trie, error)
	// CopyTrie returns an independent copy of the given trie.
	CopyTrie(Trie) Trie
}

func NewDatabase

func NewDatabase(db aoadb.Database) Database

NewDatabase creates a backing store for state. The returned database is safe for concurrent use and retains cached trie nodes in memory.

type Delegate

type Delegate struct {
	Root         common.Hash // merkle root of the storage trie
	Vote         *big.Int    // vote number
	Nickname     string      // delegate name
	RegisterTime uint64      // delegate register time
	Delete       bool        // whether delete
}

type DelegateDB

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

func New

func New(root common.Hash, db Database) (*DelegateDB, error)

Create a new state from a given trie

func (*DelegateDB) AddLog

func (d *DelegateDB) AddLog(log *types.Log)

func (*DelegateDB) AddVote

func (d *DelegateDB) AddVote(addr common.Address, amount *big.Int)

func (*DelegateDB) CommitTo

func (d *DelegateDB) CommitTo(dbw trie.DatabaseWriter, deleteEmptyObjects bool) (root common.Hash, err error)

CommitTo writes the state to the given database.

func (*DelegateDB) Copy

func (d *DelegateDB) Copy() *DelegateDB

func (*DelegateDB) Dump

func (d *DelegateDB) Dump() []byte

func (*DelegateDB) Error

func (d *DelegateDB) Error() error

func (*DelegateDB) Exist

func (d *DelegateDB) Exist(addr common.Address) bool

Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.

func (*DelegateDB) Finalise

func (d *DelegateDB) Finalise(deleteEmptyObjects bool)

Finalise finalises the state by removing the self destructed objects and clears the journal as well as the refunds.

func (*DelegateDB) ForEachStorage

func (d *DelegateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool)

func (*DelegateDB) GetDelegates

func (d *DelegateDB) GetDelegates() []types.Candidate

get current sort delegates

func (*DelegateDB) GetLogs

func (d *DelegateDB) GetLogs(hash common.Hash) []*types.Log

func (*DelegateDB) GetOrNewStateObject

func (d *DelegateDB) GetOrNewStateObject(addr common.Address, nickname string, registerTime uint64) *delegateObject

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

func (*DelegateDB) GetState

func (d *DelegateDB) GetState(a common.Address, b common.Hash) common.Hash

func (*DelegateDB) GetStateObject

func (d *DelegateDB) GetStateObject(addr common.Address) (delegateObject *delegateObject)

Retrieve a state object given my the address. Returns nil if not found.

func (*DelegateDB) GetVote

func (d *DelegateDB) GetVote(addr common.Address) *big.Int

func (*DelegateDB) HasSuicided

func (d *DelegateDB) HasSuicided(addr common.Address) bool

func (*DelegateDB) IntermediateRoot

func (d *DelegateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash

func (*DelegateDB) Logs

func (d *DelegateDB) Logs() []*types.Log

func (*DelegateDB) MarkStateObjectDirty

func (d *DelegateDB) MarkStateObjectDirty(addr common.Address)

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

func (*DelegateDB) Prepare

func (d *DelegateDB) Prepare(thash, bhash common.Hash, ti int)

func (*DelegateDB) RawDump

func (d *DelegateDB) RawDump() Dump

func (*DelegateDB) Reset

func (d *DelegateDB) Reset(root common.Hash) error

Reset clears out all emphemeral state objects from the delegate db, but keeps the underlying state trie to avoid reloading data for the next operations.

func (*DelegateDB) RevertToSnapshot

func (d *DelegateDB) RevertToSnapshot(revid int)

RevertToSnapshot reverts all state changes made since the given revision.

func (*DelegateDB) SetState

func (d *DelegateDB) SetState(addr common.Address, key common.Hash, value common.Hash)

func (*DelegateDB) SetVote

func (d *DelegateDB) SetVote(addr common.Address, amount *big.Int)

func (*DelegateDB) Snapshot

func (d *DelegateDB) Snapshot() int

Snapshot returns an identifier for the current revision of the state.

func (*DelegateDB) SubExist

func (d *DelegateDB) SubExist(addr common.Address) bool

func (*DelegateDB) SubVote

func (d *DelegateDB) SubVote(addr common.Address, amount *big.Int)

func (*DelegateDB) Suicide

func (d *DelegateDB) Suicide(addr common.Address) bool

type DelegateState

type DelegateState interface {
	SubVote(addr common.Address, amount *big.Int)
	AddVote(addr common.Address, amount *big.Int)
	GetVote(addr common.Address) *big.Int

	GetState(common.Address, common.Hash) common.Hash
	SetState(common.Address, common.Hash, common.Hash)

	// Exist reports whether the given account exists in state.
	// Notably this should also return true for suicided accounts.
	Exist(common.Address) bool

	RevertToSnapshot(int)
	Snapshot() int

	AddLog(*types.Log)

	Suicide(common.Address) bool
	HasSuicided(common.Address) bool

	ForEachStorage(common.Address, func(common.Hash, common.Hash) bool)
}

type Dump

type Dump struct {
	Root      string                  `json:"root"`
	Delegates map[string]DumpDelegate `json:"delegates"`
}

type DumpDelegate

type DumpDelegate struct {
	Vote         uint64            `json:"vote"`
	Root         string            `json:"root"`
	Nickname     string            `json:"nickname"`
	RegisterTime uint64            `json:"registerTime"`
	Storage      map[string]string `json:"storage"`
}

type Storage

type Storage map[common.Hash]common.Hash

func (Storage) Copy

func (storage Storage) Copy() Storage

func (Storage) String

func (storage Storage) String() (str string)

type Trie

type Trie interface {
	TryGet(key []byte) ([]byte, error)
	TryUpdate(key, value []byte) error
	TryDelete(key []byte) error
	CommitTo(trie.DatabaseWriter) (common.Hash, error)
	Hash() common.Hash
	NodeIterator(startKey []byte) trie.NodeIterator
	GetKey([]byte) []byte // TODO(fjl): remove this when SecureTrie is removed
}

Trie is a eminer-pro Merkle Trie.

Jump to

Keyboard shortcuts

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