devotedb

package
v0.0.0-...-774b582 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxTrieCacheGen = uint16(120)

Trie cache generation limit after which to evict trie nodes from memory.

Functions

This section is empty.

Types

type Database

type Database interface {
	// OpenTrie opens the main account trie.
	OpenTrie(root common.Hash) (Trie, error)

	// OpenStorageTrie opens the storage trie of an account.
	OpenStorageTrie(addrHash, root common.Hash) (Trie, error)

	// CopyTrie returns an independent copy of the given trie.
	CopyTrie(Trie) Trie

	// ContractCode retrieves a particular contract's code.
	ContractCode(addrHash, codeHash common.Hash) ([]byte, error)

	// ContractCodeSize retrieves a particular contracts code's size.
	ContractCodeSize(addrHash, codeHash common.Hash) (int, error)

	// TrieDB retrieves the low level trie database used for data storage.
	TrieDB() *trie.Database
}

Database wraps access to tries and contract code.

func NewDatabase

func NewDatabase(db ethdb.Database) Database

NewDatabase creates a backing store for state. The returned database is safe for concurrent use and retains cached trie nodes in memory. The pool is an optional intermediate trie-node memory pool between the low level storage layer and the high level trie abstraction.

type DevoteCache

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

func (*DevoteCache) CommitCycleTrie

func (self *DevoteCache) CommitCycleTrie(db Database, root common.Hash) error

func (*DevoteCache) CommitStatsTrie

func (self *DevoteCache) CommitStatsTrie(db Database, root common.Hash) error

func (*DevoteCache) Finalise

func (self *DevoteCache) Finalise()

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

func (*DevoteCache) GetWitnesses

func (self *DevoteCache) GetWitnesses(db Database, cycle uint64) ([]string, error)

func (*DevoteCache) Hash

func (self *DevoteCache) Hash() (h common.Hash)

func (*DevoteCache) Rolling

func (self *DevoteCache) Rolling(db Database, parentBlockTime, currentBlockTime uint64, witness string) (Trie, error)

update counts in MinerRollingTrie for the miner of newBlock

func (*DevoteCache) SetWitnesses

func (self *DevoteCache) SetWitnesses(cycle uint64, witnesses []string) error

type DevoteDB

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

func New

func New(db Database, cycleRoot, statsRoot common.Hash) (*DevoteDB, error)

Create a new state from a given trie.

func NewDevoteByProtocol

func NewDevoteByProtocol(db Database, protocol *DevoteProtocol) (*DevoteDB, error)

func (*DevoteDB) Commit

func (d *DevoteDB) Commit() (*DevoteProtocol, error)

func (*DevoteDB) Copy

func (d *DevoteDB) Copy() *DevoteDB

func (*DevoteDB) Database

func (db *DevoteDB) Database() Database

func (*DevoteDB) Exists

func (d *DevoteDB) Exists() bool

Exist reports whether the given Devote hash exists in the state. Notably this also returns true for suicided Devotes.

func (*DevoteDB) GetCycle

func (d *DevoteDB) GetCycle() uint64

func (*DevoteDB) GetStatsNumber

func (d *DevoteDB) GetStatsNumber(key []byte) uint64

func (*DevoteDB) GetWitnesses

func (d *DevoteDB) GetWitnesses(cycle uint64) ([]string, error)

func (*DevoteDB) Protocol

func (d *DevoteDB) Protocol() *DevoteProtocol

func (*DevoteDB) RevertToSnapShot

func (d *DevoteDB) RevertToSnapShot(snapshot *DevoteDB)

func (*DevoteDB) Rolling

func (d *DevoteDB) Rolling(parentBlockTime, currentBlockTime uint64, witness string)

func (*DevoteDB) Root

func (db *DevoteDB) Root() (h common.Hash)

func (*DevoteDB) SetCycle

func (d *DevoteDB) SetCycle(cycle uint64)

func (*DevoteDB) SetCycleTrie

func (d *DevoteDB) SetCycleTrie(trie Trie)

func (*DevoteDB) SetStatsTrie

func (d *DevoteDB) SetStatsTrie(trie Trie)

func (*DevoteDB) SetWitnesses

func (d *DevoteDB) SetWitnesses(cycle uint64, witnesses []string) error

func (*DevoteDB) Snapshot

func (d *DevoteDB) Snapshot() *DevoteDB

func (*DevoteDB) StorageCycleTrie

func (self *DevoteDB) StorageCycleTrie(hash common.Hash) Trie

StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.

func (*DevoteDB) StorageStatsTrie

func (self *DevoteDB) StorageStatsTrie(hash common.Hash) Trie

StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.

type DevoteProtocol

type DevoteProtocol struct {
	CycleHash common.Hash `json:"cyclehash"  gencodec:"required"`
	StatsHash common.Hash `json:"statshash"  gencodec:"required"`
	// contains filtered or unexported fields
}

func (*DevoteProtocol) Root

func (d *DevoteProtocol) Root() (h common.Hash)

type Trie

type Trie interface {
	TryGet(key []byte) ([]byte, error)
	TryUpdate(key, value []byte) error
	TryDelete(key []byte) error
	Commit(onleaf trie.LeafCallback) (common.Hash, error)
	Hash() common.Hash
	NodeIterator(startKey []byte) trie.NodeIterator
	GetKey([]byte) []byte // TODO(fjl): remove this when SecureTrie is removed
	Prove(key []byte, fromLevel uint, proofDb ethdb.Putter) error
}

Trie is a Ethereum Merkle Trie.

Jump to

Keyboard shortcuts

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