hypercore
hypercore copied to clipboard
method to enable/disable downloading
It would be useful to be able to send/receive the updated length/bitfield of a core among peers with the ability to block downloading of data.
Our use cases for this I think are mostly around authorization as well as limiting & being very targeted with bandwidth use.
This might include an option that's passed to the Hypercore constructor and a method to call to enable/disable downloading.
Should be
core.setUploading(bool)
core.setDownloading(bool)
and we should "ref" count these per session I guess
Thinking about this more, this might be more useful to set per peer when replicating.
Use case: To save bandwidth only want to upload data to a subset of peers, e.g. a peers on a local network, or a device on a low-bandwidth internet connection might choose to only upload to a single peer.
Not sure about the API for this. It looks like the peer-add
and peer-remove
events are not documented right now. But if there was an option to set the initial state of a peer to uploading=false
then the peer
object returned via peer-add
could have a setUploading(true)
method attached.
This might be tricky because would you not have to queue "wants" from a peer with uploading=false
, so that when you call setUploading(true)
on the peer, then the data is actually sent? Or is this logic already there?