package hashdb
import "github.com/ethereum/go-ethereum/triedb/hashdb"
Index ¶
- Variables
- type Config
- type Database
- func New(diskdb ethdb.Database, config *Config) *Database
- func (db *Database) Cap(limit common.StorageSize) error
- func (db *Database) Close() error
- func (db *Database) Commit(node common.Hash, report bool) error
- func (db *Database) Dereference(root common.Hash)
- func (db *Database) NodeReader(root common.Hash) (database.NodeReader, error)
- func (db *Database) Reference(child common.Hash, parent common.Hash)
- func (db *Database) Size() (common.StorageSize, common.StorageSize)
- func (db *Database) StateReader(root common.Hash) (database.StateReader, error)
- func (db *Database) Update(root common.Hash, parent common.Hash, block uint64, nodes *trienode.MergedNodeSet) error
Variables ¶
var Defaults = &Config{ CleanCacheSize: 0, }
Defaults is the default setting for database if it's not specified. Notably, clean cache is disabled explicitly,
Types ¶
type Config ¶
type Config struct { CleanCacheSize int // Maximum memory allowance (in bytes) for caching clean nodes }
Config contains the settings for database.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is an intermediate write layer between the trie data structures and the disk database. The aim is to accumulate trie writes in-memory and only periodically flush a couple tries to disk, garbage collecting the remainder.
func New ¶
New initializes the hash-based node database.
func (*Database) Cap ¶
func (db *Database) Cap(limit common.StorageSize) error
Cap iteratively flushes old but still referenced trie nodes until the total memory usage goes below the given threshold.
func (*Database) Close ¶
Close closes the trie database and releases all held resources.
func (*Database) Commit ¶
Commit iterates over all the children of a particular node, writes them out to disk, forcefully tearing down all references in both directions. As a side effect, all pre-images accumulated up to this point are also written.
func (*Database) Dereference ¶
Dereference removes an existing reference from a root node.
func (*Database) NodeReader ¶
NodeReader returns a reader for accessing trie nodes within the specified state. An error will be returned if the specified state is not available.
func (*Database) Reference ¶
Reference adds a new reference from a parent node to a child node. This function is used to add reference between internal trie node and external node(e.g. storage trie root), all internal trie nodes are referenced together by database itself.
func (*Database) Size ¶
func (db *Database) Size() (common.StorageSize, common.StorageSize)
Size returns the current storage size of the memory cache in front of the persistent database layer.
The first return will always be 0, representing the memory stored in unbounded diff layers above the dirty cache. This is only available in pathdb.
func (*Database) StateReader ¶
StateReader returns a reader that allows access to the state data associated with the specified state.
func (*Database) Update ¶
func (db *Database) Update(root common.Hash, parent common.Hash, block uint64, nodes *trienode.MergedNodeSet) error
Update inserts the dirty nodes in provided nodeset into database and link the account trie with multiple storage tries if necessary.
Source Files ¶
- Version
- v1.15.11 (latest)
- Published
- May 5, 2025
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 9 hours ago –
Tools for package owners.