diff options
author | Guillaume Ballet <gballet@gmail.com> | 2019-04-05 02:06:40 +0800 |
---|---|---|
committer | Guillaume Ballet <gballet@gmail.com> | 2019-04-08 19:21:22 +0800 |
commit | fc3000d649d8df77d21b2dc297f069715e08f5eb (patch) | |
tree | 05a9495761da74f3135f47956f67915019ecbc4d /accounts/scwallet/hub.go | |
parent | d2daff4258a66b8d0e1904095b5ebaffcb46c49e (diff) | |
download | go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.tar go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.tar.gz go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.tar.bz2 go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.tar.lz go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.tar.xz go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.tar.zst go-tangerine-fc3000d649d8df77d21b2dc297f069715e08f5eb.zip |
more review feedback
Diffstat (limited to 'accounts/scwallet/hub.go')
-rw-r--r-- | accounts/scwallet/hub.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/accounts/scwallet/hub.go b/accounts/scwallet/hub.go index 475305101..c259f711f 100644 --- a/accounts/scwallet/hub.go +++ b/accounts/scwallet/hub.go @@ -36,6 +36,7 @@ import ( "encoding/json" "io/ioutil" "os" + "path/filepath" "sort" "sync" "time" @@ -111,10 +112,11 @@ func (hub *Hub) readPairings() error { } func (hub *Hub) writePairings() error { - pairingFile, err := os.OpenFile(filepath.Join(hub.datadir,"smartcards.json"), os.O_RDWR|os.O_CREATE, 0755) + pairingFile, err := os.OpenFile(filepath.Join(hub.datadir, "smartcards.json"), os.O_RDWR|os.O_CREATE, 0755) if err != nil { return err } + defer pairingFile.Close() pairings := make([]smartcardPairing, 0, len(hub.pairings)) for _, pairing := range hub.pairings { @@ -130,15 +132,11 @@ func (hub *Hub) writePairings() error { return err } - return pairingFile.Close() + return nil } func (hub *Hub) pairing(wallet *Wallet) *smartcardPairing { - if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok{ - return &pairing - } - return nil - if ok { + if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok { return &pairing } return nil @@ -209,6 +207,7 @@ func (hub *Hub) refreshWallets() { // want to fill the user's log with errors, so filter those out. if err.Error() != "scard: Cannot find a smart card reader." { log.Error("Failed to enumerate smart card readers", "err", err) + return } } // Transform the current list of wallets into the new one |