hypercore icon indicating copy to clipboard operation
hypercore copied to clipboard

Feature request: Add per-peer control over uploading and downloading

Open gmaclennan opened this issue 5 months ago • 0 comments

This is a request to control whether a core is uploading or downloading on a per-peer basis.

Use case 1: User is on a metered internet connection (e.g. with bandwidth costs) and is connected to both local (same wifi network) and remote peers. User might want to only replicate in one direction (e.g. upload or download) with the remote peer.

Use case 2: User wants control over replicating data, but wants to know what data is available to replicate before deciding to download it. E.g. user wants to know the updated length of the core from a peer before deciding to download it.

Use case 3: With an authorization layer, a user might want to download data from a peer, but not allow uploads to that peer, e.g. for a peer that has authorization removed but still has important data that needs replicated.

It would be helpful to set a default for new peers, and add methods to control this for each peer, e.g.

const core = new Hypercore({ uploading: false, downloading: false })
core.on('peer-add', peer => {
  peer.setUploading(true)
  peer.setDownloading(true)
})

See https://github.com/holepunchto/hypercore/pull/499/files for a proof-of-concept naive implementation.

This issue supercedes https://github.com/holepunchto/hypercore/issues/305, which I think can be closed.

gmaclennan avatar Aug 29 '24 09:08 gmaclennan