From d40179f882f00e8c8c992ebc5b0bed937090e90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 23 Jun 2017 10:12:41 +0300 Subject: eth: gracefully error if database cannot be opened --- eth/backend.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3 From 01c9cf1cb5ed1f55bb6bc87c5ce18a818c5c6cec Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 23 Jun 2017 09:56:30 +0200 Subject: node: don't return non-nil database on error --- node/service.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3