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

fix: use keep-alive tag to reconnect to peers on startup #1278

Merged
merged 6 commits into from
Jun 28, 2022

Conversation

achingbrain
Copy link
Member

Instead of trying to connect to every peer in the peer store when we start a node, only connect to the peers that have been marked with a keep-alive tag.

Instead of trying to connect to every peer in the peer store when
we start a node, only connect to the peers that have been marked
with a `keep-alive` tag.

for (const peer of await this.components.getPeerStore().all()) {
const tags = await this.components.getPeerStore().getTags(peer.id)
const hasKeepAlive = tags.filter(tag => tag.name === 'keep-alive').length > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you define and export the string as a constant? I think downstream users should tag via exported constants if possible to avoid typos and confusion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened this one: libp2p/js-libp2p-interfaces#263

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind you, we want to be careful about different modules reusing tag names - otherwise one module could decide a given peer is not important any more and remove the tag, a different module would then be rug-pulled and the bug would be quite hard to track down.

@achingbrain achingbrain merged commit 2836acc into master Jun 28, 2022
@achingbrain achingbrain deleted the fix/use-keep-alive-tag-to-reconnect-on-startup branch June 28, 2022 07:05
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.

2 participants