hypercore icon indicating copy to clipboard operation
hypercore copied to clipboard

method to enable/disable downloading

Open sethvincent opened this issue 2 years ago • 3 comments

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.

sethvincent avatar Aug 22 '22 17:08 sethvincent

Should be

core.setUploading(bool)
core.setDownloading(bool)

and we should "ref" count these per session I guess

mafintosh avatar Aug 23 '22 09:08 mafintosh

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.

gmaclennan avatar Jan 16 '23 15:01 gmaclennan

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?

gmaclennan avatar Jan 16 '23 15:01 gmaclennan