diff options
author | Péter Szilágyi <peterke@gmail.com> | 2018-11-13 00:47:34 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-11-15 18:22:13 +0800 |
commit | 434dd5bc0067cdf604d84426df9086015721dd36 (patch) | |
tree | 279d85e32a36b8804d60c5a4b83b444514850782 /core/state | |
parent | 9a000601c6c4e4f8134caedba1957ffe28d2b659 (diff) | |
download | dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.gz dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.bz2 dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.lz dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.xz dexon-434dd5bc0067cdf604d84426df9086015721dd36.tar.zst dexon-434dd5bc0067cdf604d84426df9086015721dd36.zip |
cmd, core, eth, light, trie: add trie read caching layer
Diffstat (limited to 'core/state')
-rw-r--r-- | core/state/database.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/state/database.go b/core/state/database.go index c1b630991..f6ea144b9 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -72,13 +72,19 @@ type Trie interface { } // 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. +// concurrent use and retains a few recent expanded trie nodes in memory. To keep +// more historical state in memory, use the NewDatabaseWithCache constructor. func NewDatabase(db ethdb.Database) Database { + return NewDatabaseWithCache(db, 0) +} + +// NewDatabase creates a backing store for state. The returned database is safe for +// concurrent use and retains both a few recent expanded trie nodes in memory, as +// well as a lot of collapsed RLP trie nodes in a large memory cache. +func NewDatabaseWithCache(db ethdb.Database, cache int) Database { csc, _ := lru.New(codeSizeCacheSize) return &cachingDB{ - db: trie.NewDatabase(db), + db: trie.NewDatabaseWithCache(db, cache), codeSizeCache: csc, } } |