diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-06-23 16:10:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-23 16:10:29 +0800 |
commit | 46d0d04f97681b47a3be1dd3523848d387f2c3bf (patch) | |
tree | 2ed6da4f20a84450b5f14e4894adc6d640afd27b | |
parent | b751cf3901f9224903f9bb8b9e9638648e99d260 (diff) | |
parent | 01c9cf1cb5ed1f55bb6bc87c5ce18a818c5c6cec (diff) | |
download | dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.tar dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.tar.gz dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.tar.bz2 dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.tar.lz dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.tar.xz dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.tar.zst dexon-46d0d04f97681b47a3be1dd3523848d387f2c3bf.zip |
Merge pull request #14685 from karalabe/ethdb-metrics-fail-fix
eth: gracefully error if database cannot be opened
-rw-r--r-- | eth/backend.go | 5 | ||||
-rw-r--r-- | node/service.go | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/eth/backend.go b/eth/backend.go index be2d03283..75e0e737b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -200,10 +200,13 @@ func makeExtraData(extra []byte) []byte { // CreateDB creates the chain database. func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) + if err != nil { + return nil, err + } if db, ok := db.(*ethdb.LDBDatabase); ok { db.Meter("eth/db/chaindata/") } - return db, err + return db, nil } // CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service diff --git a/node/service.go b/node/service.go index 5e1eb0e64..55062a500 100644 --- a/node/service.go +++ b/node/service.go @@ -43,7 +43,11 @@ func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (et if ctx.config.DataDir == "" { return ethdb.NewMemDatabase() } - return ethdb.NewLDBDatabase(ctx.config.resolvePath(name), cache, handles) + db, err := ethdb.NewLDBDatabase(ctx.config.resolvePath(name), cache, handles) + if err != nil { + return nil, err + } + return db, nil } // ResolvePath resolves a user path into the data directory if that was relative |