eth: add hook for database creation
This commit is contained in:
parent
58d9d98daf
commit
6f8a2d6b84
@ -61,6 +61,10 @@ type Config struct {
|
|||||||
|
|
||||||
MinerThreads int
|
MinerThreads int
|
||||||
AccountManager *accounts.Manager
|
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 {
|
func (cfg *Config) parseBootNodes() []*discover.Node {
|
||||||
@ -136,11 +140,15 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
// Boostrap database
|
// Boostrap database
|
||||||
servlogger := logger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
stateDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "state"))
|
stateDb, err := newdb(path.Join(config.DataDir, "state"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user