diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-11-04 21:49:25 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-11-05 22:59:16 +0800 |
commit | 5d89bbdda18a44a22403bb3d0a3d0705ac11880d (patch) | |
tree | c404a2d0211b40936da3d3f99e5dee52ff7799cb /eth/backend.go | |
parent | e165c2d23cf29fdec51c59f42f74735be2a8e1ff (diff) | |
download | go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.tar go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.tar.gz go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.tar.bz2 go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.tar.lz go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.tar.xz go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.tar.zst go-tangerine-5d89bbdda18a44a22403bb3d0a3d0705ac11880d.zip |
eth: fix error casting regression during database open
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/eth/backend.go b/eth/backend.go index 9eb211e31..761a17a8f 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -65,7 +65,7 @@ const ( var ( jsonlogger = logger.NewJsonLogger() - datadirInUseErrNos = []uint{11, 32, 35} + datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true} portInUseErrRE = regexp.MustCompile("address already in use") defaultBootNodes = []*discover.Node{ @@ -286,15 +286,7 @@ func New(config *Config) (*Ethereum, error) { // Open the chain database and perform any upgrades needed chainDb, err := newdb(filepath.Join(config.DataDir, "chaindata")) if err != nil { - var ok bool - errno := uint(err.(syscall.Errno)) - for _, no := range datadirInUseErrNos { - if errno == no { - ok = true - break - } - } - if ok { + if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] { err = fmt.Errorf("%v (check if another instance of geth is already running with the same data directory '%s')", err, config.DataDir) } return nil, fmt.Errorf("blockchain db err: %v", err) @@ -311,14 +303,7 @@ func New(config *Config) (*Ethereum, error) { dappDb, err := newdb(filepath.Join(config.DataDir, "dapp")) if err != nil { - var ok bool - for _, no := range datadirInUseErrNos { - if uint(err.(syscall.Errno)) == no { - ok = true - break - } - } - if ok { + if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] { err = fmt.Errorf("%v (check if another instance of geth is already running with the same data directory '%s')", err, config.DataDir) } return nil, fmt.Errorf("dapp db err: %v", err) |