Skip to content

Report getmininginfo networkhashps over the getnetworkhashps window. - #1246

Merged
evoskuil merged 1 commit into
libbitcoin:masterfrom
eynhaender:fix/mininginfo-networkhashps
Nov 28, 2026
Merged

evoskuil merged 1 commit into
libbitcoin:masterfrom
eynhaender:fix/mininginfo-networkhashps

Conversation

@eynhaender

@eynhaender eynhaender commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

getmininginfo.networkhashps was computed as difficulty * 2^32 / block spacing, which is the hash rate implied by the current target rather than the observed rate. Both bitcoind and btcd answer this field with getnetworkhashps at its defaults (120 blocks ending at the top).

  • Factor the getnetworkhashps window calculation into protocol_bitcoind_mining::network_hash_ps(); getnetworkhashps behavior is unchanged.
  • Use it from the bitcoind and btcd getmininginfo handlers, with the window taken from the getnetworkhashps interface default.
  • Add tests that getmininginfo.networkhashps equals the default getnetworkhashps on both endpoints.

@evoskuil evoskuil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks correct. Both getmininginfo handlers now report over the same window as getnetworkhashps at its defaults (120 blocks ending at the confirmed top), which is what bitcoind and btcd do, and getnetworkhashps behavior is unchanged. Minor notes, none blocking:

  • The commit message has a body; the repos use a single subject line.
  • hash_ps_window = 120 duplicates the default declared in interfaces/bitcoind_mining.hpp (nullopt<120.0>), so the two can drift.
  • Statics go at the top of their section; the new static constexpr sits between an override and a method.
  • network_hash_ps can be const (archive() is const).
  • The btcd endpoint takes Core's min/max timestamp span rather than btcd's first/last block timestamps. Immaterial for a normal window.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.404% (-0.009%) from 93.413% — eynhaender:fix/mininginfo-networkhashps into libbitcoin:master

@eynhaender
eynhaender force-pushed the fix/mininginfo-networkhashps branch from 9457164 to c2d4fe9 Compare November 28, 2026 19:51
@evoskuil
evoskuil merged commit cccc7d6 into libbitcoin:master Nov 28, 2026
1 of 22 checks passed
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.

3 participants