net: store best block tip time inside PeerManager

And implement 'ApproximateBestBlockDepth()' to estimate
the distance, in blocks, between the best-known block
and the network chain tip. Utilizing the best-block time
and the chainparams blocks spacing to approximate it.
This commit is contained in:
furszy
2023-12-19 10:30:14 -03:00
parent dd391944dc
commit 97df4e3887
3 changed files with 25 additions and 6 deletions

View File

@@ -92,8 +92,8 @@ public:
/** Send ping message to all peers */
virtual void SendPings() = 0;
/** Set the best height */
virtual void SetBestHeight(int height) = 0;
/** Set the height of the best block and its time (seconds since epoch). */
virtual void SetBestBlock(int height, std::chrono::seconds time) = 0;
/* Public for unit testing. */
virtual void UnitTestMisbehaving(NodeId peer_id, int howmuch) = 0;