fix: open file used up but not closed

This commit is contained in:
songzhibin97 2024-04-21 09:34:11 +08:00
parent 2e06fbd409
commit 1d527523b0
2 changed files with 2 additions and 3 deletions

View file

@ -312,11 +312,9 @@ func (ks *KeyStore) Unlock(a accounts.Account, passphrase string) error {
// Lock removes the private key with the given address from memory. // Lock removes the private key with the given address from memory.
func (ks *KeyStore) Lock(addr common.Address) error { func (ks *KeyStore) Lock(addr common.Address) error {
ks.mu.Lock() ks.mu.Lock()
defer ks.mu.Unlock()
if unl, found := ks.unlocked[addr]; found { if unl, found := ks.unlocked[addr]; found {
ks.mu.Unlock()
ks.expire(addr, unl, time.Duration(0)*time.Nanosecond) ks.expire(addr, unl, time.Duration(0)*time.Nanosecond)
} else {
ks.mu.Unlock()
} }
return nil return nil
} }

View file

@ -95,6 +95,7 @@ func (hub *Hub) readPairings() error {
} }
return err return err
} }
defer pairingFile.Close()
pairingData, err := io.ReadAll(pairingFile) pairingData, err := io.ReadAll(pairingFile)
if err != nil { if err != nil {