Skip to content

Conversation

oooLowNeoNooo
Copy link
Contributor

Addresses the TODO comment in KeyStore.init() regarding the finalizer not triggering properly due to references held by unlocked keys.

Problem:
The runtime.AddCleanup finalizer was not triggering because unlocked keys with
active timers maintain references to the KeyStore instance, preventing garbage
collection. This could lead to resource leaks where the account cache remains
open indefinitely.

Solution:

  1. Added a Close() method to KeyStore that properly cleans up unlocked keys
    and stops their timers, allowing the finalizer to trigger correctly
  2. Added a 'closed' flag to prevent double-close issues
  3. Updated the TODO comment to explain the solution and recommend explicit
    Close() calls
  4. Added comprehensive tests for the new Close() method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant