aboutsummaryrefslogtreecommitdiffstats
path: root/core/state/database.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-11-13 00:47:34 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-11-15 18:22:13 +0800
commit434dd5bc0067cdf604d84426df9086015721dd36 (patch)
tree279d85e32a36b8804d60c5a4b83b444514850782 /core/state/database.go
parent9a000601c6c4e4f8134caedba1957ffe28d2b659 (diff)
downloadgo-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.tar
go-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.tar.gz
go-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.tar.bz2
go-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.tar.lz
go-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.tar.xz
go-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.tar.zst
go-tangerine-434dd5bc0067cdf604d84426df9086015721dd36.zip
cmd, core, eth, light, trie: add trie read caching layer
Diffstat (limited to 'core/state/database.go')
-rw-r--r--core/state/database.go14
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,
}
}