Skip to content

Commit 1cd0048

Browse files
authored
accounts/keystore: use runtime.AddCleanup (#32610)
1 parent 8dfd30f commit 1cd0048

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

accounts/keystore/keystore.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ func (ks *KeyStore) init(keydir string) {
9999
// TODO: In order for this finalizer to work, there must be no references
100100
// to ks. addressCache doesn't keep a reference but unlocked keys do,
101101
// so the finalizer will not trigger until all timed unlocks have expired.
102-
runtime.SetFinalizer(ks, func(m *KeyStore) {
103-
m.cache.close()
104-
})
102+
runtime.AddCleanup(ks, func(c *accountCache) {
103+
c.close()
104+
}, ks.cache)
105+
105106
// Create the initial list of wallets from the cache
106107
accs := ks.cache.accounts()
107108
ks.wallets = make([]accounts.Wallet, len(accs))

0 commit comments

Comments
 (0)