-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Add P2P functionality #666
base: develop
Are you sure you want to change the base?
Conversation
Add P2P bootstrap and register behaviour to the polka-storage-provider-server.
13fb051
to
a3e3803
Compare
token: CancellationToken, | ||
) -> Result<(), P2PError> { | ||
info!("Starting P2P bootstrap node"); | ||
let tracker = TaskTracker::new(); |
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.
What's the reason for using tracker here? Can't we just spawn the task and await it in a select?
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.
The tracker is used to ensure a graceful shutdown by waiting for the p2p task to shutdown after the cancellation token has been invoked.
|
||
/// Register the peer with the rendezvous point. | ||
/// The ttl is how long the peer will remain registered in seconds. | ||
async fn register( |
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.
I don't understand why we need to have two different swarms :( I'll need to read up on that.
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.
We need two swarms because each node behaves differently. Since we are not enforcing every storage provider to be a bootstrap node, we cannot require the bootstrap behaviour on a registration node. More information on swarm behaviour
Description
This PR adds bootstrap and registration p2p node functionality to the polka-storage-provider-server. The node type is selected by passing the node-type argument into the CLI (bootstrap or registration). Configuration is read from a TOML file, see the example in the p2p-example-config folder. The P2P network supports an ED25519 private key in PEM file format.
The
generate-peer-id
command has been added to the polka-storage-provider-client. This command generates a peer ID from an ED25519 public key PEM file and writes it to a file or stdout, depending on the--file
argument.Note:
I have not added any P2P discovery, this will be implemented in the fetching application. I can add a discovery example if needed.