So far, the GetLatestBlockHeight function of the Electrum client was using go-electrum's 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 with one item inside.
Here we replace SubscribeHeaders with SubscribeHeadersSingle which does not create a goroutine supposed to handle future headers notifications. The SubscribeHeadersSingle just returns the current chain tip and ignores further notifications coming from the Electrum server.
Closes: https://github.com/keep-network/keep-core/issues/3739 Depends on: https://github.com/keep-network/go-electrum/pull/5 Depends on: https://github.com/keep-network/keep-core/pull/3774
So far, the
GetLatestBlockHeight
function of the Electrum client was usinggo-electrum
'sSubscribeHeaders
under the hood. That caused a memory leak becauseGetLatestBlockHeight
was not interested in reading from the returnedheadersChan
channel. Each call toGetLatestBlockHeight
produced a new dangling goroutine blocked on a buffered channel with one item inside.Here we replace
SubscribeHeaders
withSubscribeHeadersSingle
which does not create a goroutine supposed to handle future headers notifications. TheSubscribeHeadersSingle
just returns the current chain tip and ignores further notifications coming from the Electrum server.See https://github.com/keep-network/go-electrum/pull/5 for further reference.