keep-network / go-electrum

A pure Go ElectrumX JSON-RPC library.
MIT License
0 stars 10 forks source link

Expose the `SubscribeHeadersSingle` function #5

Closed lukasz-zimnoch closed 9 months ago

lukasz-zimnoch commented 9 months ago

Refs: https://github.com/keep-network/keep-core/issues/3739

The SubscribeHeadersSingle function subscribes to receive the header of the current blockchain tip. Unlike SubscribeHeaders, this function only returns the tip and does not listen for new block headers.

Worth noting that this action still creates a new subscription in the Electrum server. The protocol does neither support a single-shot request for the current blockchain tip nor subscription cancellation. Although this limitation causes a slight resource overhead on the client, it does not cause a memory leak like the SubscribeHeaders method which spawns a goroutine that may hang on the channel if the caller is no longer pulling from it.