This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Add bootstrap node and peer list exchange and automatique connection #40
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tuommaki
reviewed
Jan 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor notes. In general LGTM 🙂
crates/node/Cargo.toml
Outdated
@@ -22,6 +22,7 @@ hex = "0.4" | |||
home = "0.5" | |||
jsonrpsee = { version = "0.20", features = [ "client", "server" ] } | |||
libsecp256k1 = "0.7" | |||
log = "0.4.20" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I miss it. Removed.
tuommaki
approved these changes
Jan 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the log
dependency, this LGTM 👍
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add node peers list propagation.
When a node connects to another one, they exchange their peer list. If there's a missing connection, the node connects to the missing node. So one node connected to another, it gets all not connected nodes and connect to them.
To start, a bootstrap node must be specified. This part has not been changed. The node use the config to get one peer to connect to. When it connects, it gets all peer list and open a connection to them.
It's a raw version but seems to work.
Some edge cases are not completely managed. For example, if 2 nodes (2,3) connect at the same time to one node 1. Node 2 and 3 get the other address from node 1 and try to connect each other at the same time. So it opens 2 connections between both nodes, which is not allowed. So the lib close one. From my tests, only one is closed and not both.
Node disconnection is not completely tested. From my tests, to be notified of a disconnection, the disconnect function must be called. I'll do more test with real host to see how it works. Node disconnection remove unused nodes from the exchanged peer list.
I've tested using the unit test. I create 2 tests that seems to work locally.