bltavares / colmeia

Attempt to make an interop layer to connect to dat on hyperswarm in Rust
24 stars 4 forks source link

Handle discovery of multiple feeds #22

Closed bltavares closed 3 years ago

bltavares commented 4 years ago

Currently, colmeia has been working with as single hypercore concept.

@Frando has been very kind to share some of his early work on his hypercore-replicator crate, which the design supports replicating multiple feeds.

Hyperdrive, the filesystem abstraction built on top of hypercores, has to replicate at least 2 cores. This is noticeable when debuging MDNS discovery messages where we receive multiple feeds at once.

This is also how JS is replicating the data. Now, there is a corestore and the hyperspace API in JS, which is this broader abstraction of maintaining multiple feeds in sync at once.

To align better with @Frando's hypercore-replicator, which is a quite nice API, this issue documents the need to change how Colmeia deals with single feeds vs multiple feeds.

Concern

Currently, to replicate and discover multiple hypercores in colmeia, it would need to create multiple Hypercore Stacks (as on #21), which means opening multiple sockets at once. That means that each hyperdrives (pairs of cores) would allocate one listener socket, one discovery mdns responder socket and one mdns discovery. Given we are targeting mobile (and possibly routers), that is a bit wasteful.

It would better fit to redesign colmeia-hyperswarm-mdns to be able to add new feed keys (and removal), so we can discover multiple feeds on the network with a single socket.