holepunchto / hypercore

Hypercore is a secure, distributed append-only log.

Home Page:https://docs.holepunch.to

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

event for listening to bitfield updates

sethvincent opened this issue · comments

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.

Maybe something like:

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

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

@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.