-
Notifications
You must be signed in to change notification settings - Fork 59
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 NodeSpawner
and NetworkSpawner
#2642
feat: add NodeSpawner
and NetworkSpawner
#2642
Conversation
451f342
to
e6a4fc5
Compare
|
||
/// Once a node is started and running, the user obtains | ||
/// a `NodeRunning` object which can be used to interact with it. | ||
#[derive(Clone)] | ||
pub struct RunningNode { | ||
shutdown_sender: watch::Sender<bool>, |
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 send TerminateNode(String)
via the NodeEventsChannel
below, can this be re-used here?
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.
It could be reused for the node (NodeEvents
) loop, but for the SwarmDriver
loop it wouldn't make sense, as the broadcast channel uses ant_node::event::NodeEvent
, which is inaccessible from the ant-networking
crate in which the SwarmDriver
loop resides.
fbfd2a0
to
c8909d6
Compare
bcef93e
to
17b0f20
Compare
66e4e9a
to
73f902b
Compare
@@ -280,10 +285,15 @@ | |||
// TODO: Think about handling the mDNS error here. | |||
let (network, event_receiver, swarm_driver) = network_builder.build_client(); | |||
|
|||
let _swarm_driver = ant_networking::time::spawn(swarm_driver.run()); | |||
// TODO: Implement graceful SwarmDriver shutdown for client. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
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.
for the files under the spawn
, as the file names of network.rs
and node.rs
is very similar to the existing Node
Network, can they be renamed to
network_spawner.rs
node_spawner.rs` to match the struct names ?
Also, seems the functions within the NetworkSpawner and NodeSpawner are very much similar to the existing ones, for example ant_node\src\bin\antnode\main.rs::create_secret_key_file
I am wondering why there is new duplicated functions as well?
It seems NetworkSpawner
and NodeSpawner
are two utility wrapping struct
, which seems the PR title is bit misleading.
Shall the PR Title change to: Add NodeSpawner and NetworkSpawner ?
Ah yes, great suggestion!
Functions like
Sure, makes sense! |
NodeSpawner
and NetworkSpawner
REQUIRES mDNS REMOVAL PR: #2652
Adds the option to spawn nodes and networks from code using
NodeSpawner
andNetworkSpawner
.TODO: