diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-14 01:32:26 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-14 01:41:09 +0800 |
commit | 6f8a2d6b84f0ef3f783fa86bbb97c357ab0cb0c2 (patch) | |
tree | eeeb1945130e9a67ab00d3198a37fa106be06318 /eth | |
parent | 58d9d98dafc9013a4aa6f7f2c8c8e3d9ad76ce7c (diff) | |
download | go-tangerine-6f8a2d6b84f0ef3f783fa86bbb97c357ab0cb0c2.tar.gz go-tangerine-6f8a2d6b84f0ef3f783fa86bbb97c357ab0cb0c2.tar.zst go-tangerine-6f8a2d6b84f0ef3f783fa86bbb97c357ab0cb0c2.zip |
eth: add hook for database creation
Diffstat (limited to 'eth')
-rw-r--r-- | eth/backend.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/eth/backend.go b/eth/backend.go index 9c497a586..2c7c7d792 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -61,6 +61,10 @@ type Config struct { MinerThreads int AccountManager *accounts.Manager + + // NewDB is used to create databases. + // If nil, the default is to create leveldb databases on disk. + NewDB func(path string) (ethutil.Database, error) } func (cfg *Config) parseBootNodes() []*discover.Node { @@ -136,11 +140,15 @@ func New(config *Config) (*Ethereum, error) { // Boostrap database servlogger := logger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat) - blockDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "blockchain")) + newdb := config.NewDB + if newdb == nil { + newdb = func(path string) (ethutil.Database, error) { return ethdb.NewLDBDatabase(path) } + } + blockDb, err := newdb(path.Join(config.DataDir, "blockchain")) if err != nil { return nil, err } - stateDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "state")) + stateDb, err := newdb(path.Join(config.DataDir, "state")) if err != nil { return nil, err } |