hypercore icon indicating copy to clipboard operation
hypercore copied to clipboard

event for listening to bitfield updates

Open sethvincent opened this issue 3 years ago • 3 comments
trafficstars

It would be useful to be able to listen to an event on the core and for each peer in core.peers to find out when a bitfield is updated. The end goal for this would be to create diffs of the bitfield changes. For example, this event might provide something like the values used in Peer.onbitfield & Peer.onrange.

sethvincent avatar Aug 25 '22 18:08 sethvincent

Maybe something like:

core.on('peer-update', function (peer) {
  ...
})

mafintosh avatar Aug 25 '22 18:08 mafintosh

Obvs that requires queries on the remoteBitfield to be practical (ie, fast has(start, end))

mafintosh avatar Aug 25 '22 18:08 mafintosh

@mafintosh any further thoughts on whether this is possible / practical?

Use case: know what data / size of data that needs to be uploaded to / downloaded from a particular peer, ultimately to know whether replication has "finished" e.g. all data that can be sent has been sent, and all data that can be received can be received. But also to provide a user feedback on progress of replication and an estimation of time to completion.

gmaclennan avatar Jan 16 '23 15:01 gmaclennan