eth: gracefully error if database cannot be opened

This commit is contained in:
Péter Szilágyi 2017-06-23 10:12:41 +03:00
parent b664bedcf2
commit d40179f882
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D

View File

@ -200,10 +200,13 @@ func makeExtraData(extra []byte) []byte {
// CreateDB creates the chain database. // CreateDB creates the chain database.
func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) {
db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles)
if err != nil {
return nil, err
}
if db, ok := db.(*ethdb.LDBDatabase); ok { if db, ok := db.(*ethdb.LDBDatabase); ok {
db.Meter("eth/db/chaindata/") db.Meter("eth/db/chaindata/")
} }
return db, err return db, nil
} }
// CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service // CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service