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

Muxing multiple corestores in the same stream breaks discovery key hook #45

Open
gmaclennan opened this issue Jan 25, 2023 · 0 comments

Comments

@gmaclennan
Copy link

The docs suggest that corestore can replicate to an existing stream, e.g. a connection stream from Hyperswarm like so:

const swarm = new Hyperswarm()

// join the relevant topic
swarm.join(...)

// simply pass the connection stream to corestore
swarm.on('connection', (connection) => store.replicate(connection))

This does work, however if you try to replicate any other corestore or hypercore to the stream before this, then the discovery key hook in corestore does not work, meaning that un-opened cores which exist on the peer are not replicated.

This seems to be because the Protomux stream is only created once, when the first hypercore or corestore is replicated to the stream, and the ondiscoverykey hook only works on that first replication.

I have created a failing test for this (#44) which replicates a third (unrelated) corestore to the connection stream. Removing the line results in the test passing.

This may be intended behaviour, in which case it would be helpful if the docs clarify that if you replicate to an existing stream, you can only replicate one corestore to that stream, and it must be replicated to that stream before any other hypercores.

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

No branches or pull requests

1 participant