-
Notifications
You must be signed in to change notification settings - Fork 0
refactor updates #18
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
refactor updates #18
Conversation
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.
Made suggestions on required changes
|
@AlvinHon Please also advise on whether EngineCommand should be moved into engine.rs or in peer.rs |
It should be in engine.rs. |
|
I have some comments:
|
src/peer.rs
Outdated
| pub async fn start(config: Config, handlers: Vec<Box<dyn Fn(PublicAddress, Message) + Send>>) -> Result<Peer, PeerStartError> { | ||
| let swarm = set_up_transport(&config).await?; | ||
| let swarm = establish_network_connections(swarm, &config)?; | ||
| let (handle, sender) = main_loop(swarm, &config, handlers)?; |
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.
"main_loop" doesn't seem to be a good naming...?
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 agree, maybe "spawn_event_loop" , "start_event_detection" or "spawn_events_handler" ? any suggestions?
src/messages.rs
Outdated
| impl TryFrom<(libp2p::gossipsub::Message, pchain_types::cryptography::PublicAddress)> for Message { | ||
| type Error = MessageConversionError; | ||
|
|
||
| fn try_from((message , local_public_address): (libp2p::gossipsub::Message, pchain_types::cryptography::PublicAddress)) |
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.
Move this and the MessageConversionError into conversions.rs as these are all related to conversions
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.
Comments on minor changes before merging
Changes
TryFrom<libp2p::gossipsub::Message>for pchain Message.