You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We track height and total_difficulty for all our connected peers on the PeerLiveInfo struct.
These are updated when we handle Ping and Pong messages. These are the only places we update height and total_difficulty for a connected peer.
Surprisingly we do not update these when we process and accept a new block header... and we must wait (potentially up to 10s) for the next Ping or Pong to arrive to update the peer in our list of connected peers.
I am not entirely sure what the implications of this unnecessary delay means but its probably not great.
Proposal
We should update height and total_difficulty as soon as we accept a valid block header (or compact block or full block) from a peer (if this increases total_difficulty).
We should then update height and total_difficulty for any peer that subsequently sends us that header, compact_block or full block, even if we treat this as "already known" on our side.
Why update peer on block header and not just a full block? As soon as a peer sends us a new block header it is advertising that it indeed has this full block. In the same way as a Ping/Pong advertises the existence of a block with certain total_difficulty and height.
The block_accepted() on the chain adapter might be a good approach to this, but we likely need a header_accepted() as well. And we'll need to consider the peer locks carefully.
Related
The Hand and Shake msgs include total_difficulty but do not include height.
We do not use this total_difficulty when initializing the PeerLiveInfo for the connected peer.
Edit: We do use this, but we don't have the height which is why these appear as 0 on the tui during startup.
We should probably add height to these msgs for completeness or maybe just fire off a Ping as soon as the handshake negotiation has completed successfully.
The text was updated successfully, but these errors were encountered:
Problem
We track
height
andtotal_difficulty
for all our connected peers on thePeerLiveInfo
struct.These are updated when we handle
Ping
andPong
messages. These are the only places we updateheight
andtotal_difficulty
for a connected peer.Surprisingly we do not update these when we process and accept a new block header... and we must wait (potentially up to 10s) for the next
Ping
orPong
to arrive to update the peer in our list of connected peers.I am not entirely sure what the implications of this unnecessary delay means but its probably not great.
Proposal
We should update
height
andtotal_difficulty
as soon as we accept a valid block header (or compact block or full block) from a peer (if this increases total_difficulty).We should then update
height
andtotal_difficulty
for any peer that subsequently sends us that header, compact_block or full block, even if we treat this as "already known" on our side.Why update peer on block header and not just a full block? As soon as a peer sends us a new block header it is advertising that it indeed has this full block. In the same way as a Ping/Pong advertises the existence of a block with certain total_difficulty and height.
The
block_accepted()
on the chain adapter might be a good approach to this, but we likely need aheader_accepted()
as well. And we'll need to consider the peer locks carefully.Related
The
Hand
andShake
msgs includetotal_difficulty
but do not includeheight
.We do not use thistotal_difficulty
when initializing thePeerLiveInfo
for the connected peer.Edit: We do use this, but we don't have the height which is why these appear as 0 on the tui during startup.
We should probably add
height
to these msgs for completeness or maybe just fire off aPing
as soon as the handshake negotiation has completed successfully.The text was updated successfully, but these errors were encountered: