diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-11-28 19:29:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-28 19:29:16 +0800 |
commit | 8d0108fc5df81c71010b9dfb11a5db5658fcb80a (patch) | |
tree | ef60472426e44d6c31ca4fac123a8c872296c0e1 /accounts | |
parent | ba41efa8a0365912ab26b24cb4ac46153e774d4f (diff) | |
parent | 91bceb4acee23b1c92b288dd3a301a98eba9f4d3 (diff) | |
download | go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.tar go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.tar.gz go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.tar.bz2 go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.tar.lz go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.tar.xz go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.tar.zst go-tangerine-8d0108fc5df81c71010b9dfb11a5db5658fcb80a.zip |
Merge pull request #3355 from fjl/hexutil-2
Improve hex encoding/decoding
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/addrcache.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/accounts/addrcache.go b/accounts/addrcache.go index 0a904f788..a99f23606 100644 --- a/accounts/addrcache.go +++ b/accounts/addrcache.go @@ -225,7 +225,7 @@ func (ac *addrCache) scan() ([]Account, error) { buf = new(bufio.Reader) addrs []Account keyJSON struct { - Address common.Address `json:"address"` + Address string `json:"address"` } ) for _, fi := range files { @@ -241,15 +241,16 @@ func (ac *addrCache) scan() ([]Account, error) { } buf.Reset(fd) // Parse the address. - keyJSON.Address = common.Address{} + keyJSON.Address = "" err = json.NewDecoder(buf).Decode(&keyJSON) + addr := common.HexToAddress(keyJSON.Address) switch { case err != nil: glog.V(logger.Debug).Infof("can't decode key %s: %v", path, err) - case (keyJSON.Address == common.Address{}): + case (addr == common.Address{}): glog.V(logger.Debug).Infof("can't decode key %s: missing or zero address", path) default: - addrs = append(addrs, Account{Address: keyJSON.Address, File: path}) + addrs = append(addrs, Account{Address: addr, File: path}) } fd.Close() } |