Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount extensions on channel, support mux on top of corestore & corestore-swarm-networker #45

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Frando
Copy link
Member

@Frando Frando commented Jun 10, 2020

Currently the mux extensions are mounted on the main hypercore-protocol stream and not on a channel. This is why multifeed has to "own" the protocol stream (you can't pass in an existing stream into multifeed's replicate method at the moment).

I wanted to look how to use multifeed on top of corestore and with corestore-swarm-networking because this is what the dat-sdk uses, also hyperdrive needs corestore and we use it in sonar too.

The main challenge is that with hyperswarm, you don't know for which topic an incoming connection is opened. Therefore, we first open the channel with the encryptionKey (multifeed root key). Onto this mux channel the extensions are mounted.

All tests pass. One regression test had to be altered: When replicating with wrong keys, this is not an error but a timeout now. This might be intended or not, I'm not sure. Basically it waits until the other end will open a channel on the mux root key you passed. Before, it would wait for the first channel opened and error out if its the wrong one. This doesn't work in this model because there might be legitimate other channels. This will also allow to replicate multiple multifeeds over the same protocol stream! Like all shared cabals can sync on one stream between two peers.

This PR also adds a corestore.js export that has a wrapper around the mux protocol without anything else in multifeed. See test/corestore.js for now - it makes it really straightfoward to use the mux protocol with corestore and corestore-swarm-networker.

I also added a test that replicates a multifeed into a corestore+mux over hyperswarm.

I don't know if I have time for this much more. I wrote most of this some time back but never published. @kyphae and @okdistribute both recently expressed interest in this so I went over it a little and share it here now.

This PR also updates hypercore to v9, otherwise multifeed-corestore sync wouldn't work because of handshake changes. This of course likely should be a seperate patch. On the other hand, this PR would combine two wire protocol breaking changes, and with these make multifeed fully compatible with how things are done in dat-sdk and hyperdrive-daemon.

Before, the extensions where mounted on the stream and not on a channel.
Now, the extensions are mounted on the channel that is opened with the
root key. This makes it possible to mount the mux extensions onto any
existing hypercore-protocol stream, multifeed does not have to own the
stream. This will allow to make multifeed compatible with corestore and
corestore-swarm-networker.
Exposes a CorestoreMuxer that makes the mux extensions usable on top of
corestore and corestore-swarm-networker.

See test/corestore.js for test and example.
@okdistribute
Copy link
Member

+1 to 'all shared cabals can sync on one stream between two peers.'

@m4gpi
Copy link

m4gpi commented Jun 15, 2020

great!!! 💥

@Frando
Copy link
Member Author

Frando commented Jun 29, 2020

So I've been continuing a bit on this: I have a version of multifeed that runs on top of corestore. It uses a hypercore to locally store the list of feeds that make up a multifeed, uses corestore namespaces, and connects the muxer via corestore-swarm-networking.

See my fork @frando/corestore-multifeed. With the changes in this PR, which are unrelated to adding any corestore related code, multifeed would be fully network compatible with this corestore-multifeed module.

Therefore I'm reducing the scope of this PR to just the actual change: Mount the extensions on a channel.

The question of whether the "default" multifeed model would use corestore or not can be a seperate question then. For that, I'd be interested to know what current multifeed users are thinking about using corestore for storage?

Independently of that I think the protocol change in this PR makes sense on its own, and allows for replicating many multifeeds over the same stream, and allows to be compatible to the @frando/corestore-multifeed approach.

@hackergrrl
Copy link
Member

Looks good to me. 👍

@DougAnderson444
Copy link
Contributor

Hey gang! Any update on when this might get merged? I've been using this fork with pretty good success with a couple small tweaks.

@Frando and @kyphae I did make a few very small changes PR'd on gitlab (https://gitlab.com/coboxcoop/multifeed/-/merge_requests) that should be merged before this branch gets merged here too. Not sure who is pulling in changes over there.

@hackergrrl
Copy link
Member

hackergrrl commented Nov 18, 2020

@DougAnderson444 Still remaining:

  • rebase & resolve conflicts (anyone)
  • merge + publish (anyone with kappa-db ownership)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants