Closed roylee17 closed 2 years ago
I was getting worried that chainwork/mediantime had no implementation in "lbcd", but found what I needed here:
https://github.com/lbryio/lbcd/blob/7f9fe4b97058830be58f79e8a54530863d5cd829/blockchain/blockindex.go#L188 https://github.com/lbryio/lbcd/blob/7f9fe4b97058830be58f79e8a54530863d5cd829/blockchain/blockindex.go#L82
Yeah, the mediantime
is part of consensus, so it must be existing somewhere.
The chainwork
, however, in lbcd currently has different semantics - accounting works since each restart of lbcd, instead of historically accumulated numbers. It works for the chain as it only cares about the relative work between branches, if any, for choosing the one with most work.
Currently, the only known external users of that field is block explorers for displaying information. While it probably won't block any functional integration, still very nice to have if we can reconstruct/calculated the accumulated work at start-up.
All the code I investigate indicates chainwork (workSum
) is predictable, and is initialized during the "Loading block index" phase:
initBlockNode()
is where the parent workSum
is added. This seems consistent across bcd, lbrycrd, and C++ bitcoin. It's "in memory only" but gets recomputed during startup.
Maybe there is some separate concept with a similar purpose/name that you are thinking of?
I didn't dig too deep into that last time, so you maybe right, which would be a good news.
You can test against a public lbrycrd instance I setup for validation when you export it to the rpcserver.
lbcctl --notls -s 18.221.146.233 -u rpcuser -P rpcpass getblock ac280c2a68c57707cc1fedbd025782c76cc2679550aa18cc5bd6e3f64c2a2769
Missing
chainwork
andmediantime
On lbcd:
On lbrycrd: