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

cache bitcoin height from process btc block #236

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

ClaytonNorthey92
Copy link
Contributor

@ClaytonNorthey92 ClaytonNorthey92 commented Aug 28, 2024

Summary
As of now, each time pop miner wants to mine they call bfgapi.BitcoinInfoRequest to get the height. Bitcoin height doesn't change that often (not enough to be reaching out to the client in every single request at least).

We have another goroutine that gets the height on a 5 second timer; piggy-back off of this to set a server-value of the btc height from the last success in this goroutine. This way, clients (i.e. pop miners) don't make a call to electrumx when getting bitcoin info.

Changes
use the result of another go routine's btcClient.Height to set a cached height value.

this would be at most 5 seconds out-of-sync with electrumx

@github-actions github-actions bot added the area: bfg This is a change to BFG (Bitcoin Finality Governor) label Aug 28, 2024
@ClaytonNorthey92 ClaytonNorthey92 marked this pull request as ready for review August 28, 2024 17:23
@ClaytonNorthey92 ClaytonNorthey92 requested a review from a team as a code owner August 28, 2024 17:23
Copy link
Contributor

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@ClaytonNorthey92 ClaytonNorthey92 merged commit f4b877f into main Aug 29, 2024
6 checks passed
@ClaytonNorthey92 ClaytonNorthey92 deleted the clayton/height-cache branch August 29, 2024 01:04
web3cryptoguy pushed a commit to web3cryptoguy/heminetwork that referenced this pull request Nov 1, 2024
* cache bitcoin height from process btc block

* skipping irrelevant test

* check for notification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: bfg This is a change to BFG (Bitcoin Finality Governor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants