holepunchto / hyperswarm

A distributed networking stack for connecting peers.
https://docs.holepunch.to
MIT License
1.06k stars 85 forks source link

feat(swarm): share DHT node between multiple swarm peers #107

Closed Nuhvi closed 1 year ago

Nuhvi commented 2 years ago

Creating multiple Hyperswarm Peers/nodes is useful, but DHT bootstrapping is expensive, this PR tries to fix that.

This a long shot I know, and its not blocking anyone, but I thought it might be interesting to consider.

Inspired by corestore.namespace() API

mafintosh commented 2 years ago

Interesting! @kasperisager @andrewosh mb someone has a better api name? Not a huge fan of “child” as it’s not really a tree

Nuhvi commented 2 years ago

@mafintosh I agree. Destroying a "child" won't destroy "deeper children", but at least they are all going to be destroyed once the "root" (the one Node that bootstrapped the DHT itself) is destroyed, so I don't know what to call that pattern.

clone() is the best I got for now.

Nuhvi commented 2 years ago

swarm.session() ?

smoyer64 commented 2 years ago

What about hive?

On Mon, May 23, 2022 at 2:12 AM Ar Nazeh @.***> wrote:

swarm.session() ?

— Reply to this email directly, view it on GitHub https://github.com/hyperswarm/hyperswarm/pull/107#issuecomment-1134223990, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQFDKDPFIWLFR4WGHHQSTVLMOVBANCNFSM5WEAU4MQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Sent from my iBerry MacPhone

Nuhvi commented 2 years ago

The closest pattern I could find, but it is more relevant to memory sharing not networking https://en.wikipedia.org/wiki/Flyweight_pattern

mafintosh commented 2 years ago

Session is the closest to terminology we already use 👍

Nuhvi commented 2 years ago

@mafintosh renamed

LuKks commented 1 year ago

@Nazeh do you mind if I rebase? It's a really cool feature

LuKks commented 1 year ago

Maybe the event could be called predestroy so that way it's explicit that this is happening before actually destroying resources. It could be an opportunity to also emit once a close event at the end, so it's consistent with all other libs

Nuhvi commented 1 year ago

@LuKks don't mind at all.

LuKks commented 1 year ago

I wasn't sure how to force-push on this PR, GitHub has some instructions but not very clear as it involves master branch:

Step 1: From your project repository, check out a new branch and test the changes.

git checkout -b Nazeh-child-nodes master
git pull git@github.com:Nazeh/hyperswarm.git child-nodes
Step 2: Merge the changes and update on GitHub.

git checkout master
git merge --no-ff Nazeh-child-nodes
git push origin master

Seems riskier than just opening a new PR

Nuhvi commented 1 year ago

closing this, #130 is further ahead.