Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Fix a memory leak in Electrum client #3781

Merged

Conversation

lukasz-zimnoch
Copy link
Member

This pull request backports #3775 to the releases/mainnet/v2.0.0-m7 branch.

This is done in order to pull changes introduced in
keep-network/go-electrum#5

(cherry picked from commit b3b800c)
So far, `GetLatestBlockHeight` function used `SubscribeHeaders` under the hood.
That caused a memory leak because `GetLatestBlockHeight` was not interested
in reading from the returned `headersChan` channel. Each call to
`GetLatestBlockHeight` produced a new dangling goroutine blocked on a buffered
channel holding one item

Here we replace `SubscribeHeaders` with `SubscribeHeadersSingle` which
does not create a goroutine supposed to handle future headers notifications.
The `SubscribeHeadersSingle` just return the current chain tip and ignores
further notifications coming from the Electrum server.

See keep-network/go-electrum#5 for further reference.

(cherry picked from commit fb91c33)
@lukasz-zimnoch lukasz-zimnoch self-assigned this Feb 12, 2024
@lukasz-zimnoch lukasz-zimnoch added this to the v2.0.0-m7 milestone Feb 12, 2024
@lukasz-zimnoch lukasz-zimnoch marked this pull request as ready for review February 12, 2024 09:42
@lukasz-zimnoch lukasz-zimnoch merged commit 6d88921 into releases/mainnet/v2.0.0-m7 Feb 12, 2024
27 of 28 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the backport-fix-electrum-mem-leak branch February 12, 2024 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants