diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index b9184a2334..df3dda60b6 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -312,8 +312,9 @@ func (ks *KeyStore) Unlock(a accounts.Account, passphrase string) error { // Lock removes the private key with the given address from memory. func (ks *KeyStore) Lock(addr common.Address) error { ks.mu.Lock() - defer ks.mu.Unlock() - if unl, found := ks.unlocked[addr]; found { + unl, found := ks.unlocked[addr] + ks.mu.Unlock() + if found { ks.expire(addr, unl, time.Duration(0)*time.Nanosecond) } return nil diff --git a/cmd/utils/history_test.go b/cmd/utils/history_test.go index 520a0d84cd..b6703c59ed 100644 --- a/cmd/utils/history_test.go +++ b/cmd/utils/history_test.go @@ -113,7 +113,6 @@ func TestHistoryImportAndExport(t *testing.T) { if err != nil { t.Fatalf("error opening era file: %v", err) } - defer f.Close() var ( h = sha256.New() buf = bytes.NewBuffer(nil)