-
Notifications
You must be signed in to change notification settings - Fork 964
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
Make the structs in nodes generic over PeerId #881
Conversation
// Set the state of the task to `Connected`. | ||
let former_task_id = self.parent.nodes.insert(self.peer_id.clone(), self.id); | ||
let _former_state = self.parent.tasks.insert(self.id, TaskState::Connected(self.peer_id.clone())); | ||
debug_assert_eq!(_former_state, Some(TaskState::Pending)); | ||
debug_assert!(_former_state == Some(TaskState::Pending)); |
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.
Why the change from debug_assert_eq
to debug_assert
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.
Otherwise we have to require Debug
on the TPeerId
.
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.
Is this not required here? https://github.com/libp2p/rust-libp2p/pull/881/files#diff-87276c9dd75246456f7330545b24dd12R128
TPeerId: Eq + Hash + Clone + fmt::Debug,
Edit: Oh, I understand. Impl <…> fmt::Debug for … TPeerId: … + fmt::Debug
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.
🎆
Instead of hard-coding the ID of a peer as
PeerId
, make it generic.This is a small breaking change as we implement
AsRef<[u8]>
onPeerId
, which can cause an inference error, but we can consider this as acceptable.