-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support deletes #68
Support deletes #68
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use crate::proto::msg as message; | ||
use crate::proto::snapchain; | ||
|
||
impl message::Message { | ||
pub fn is_type(&self, message_type: message::MessageType) -> bool { | ||
|
@@ -20,4 +21,20 @@ impl message::Message { | |
0 | ||
} | ||
} | ||
|
||
pub fn hex_hash(&self) -> String { | ||
hex::encode(&self.hash) | ||
} | ||
} | ||
|
||
impl snapchain::ValidatorMessage { | ||
pub fn fid(&self) -> u32 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things:
impl snapchain::ValidatorMessage {
pub fn fid(&self) -> u32 {
if let Some(fname) = &self.fname_transfer {
return fname.fid as u32;
}
if let Some(event) = &self.on_chain_event {
return event.fid as u32;
}
0
}
} I think upon seeing the unwrap there I really have to scrutinize the code, and it took me a moment to realize that it was indeed safe due to the is_some() above. I think we can probably remove most of the unwraps() in this file with similar refactors and it will be MUCH faster to reason about, especially at a glance.
Maybe 0 is fine, but perhaps a comment? Or a TODO for end state? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if let Some(fname) = &self.fname_transfer { | ||
return fname.fid as u32; | ||
} | ||
if let Some(event) = &self.on_chain_event { | ||
return event.fid as u32; | ||
} | ||
0 | ||
} | ||
} |
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.
don't think this made it into the PR?
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 did. This is what implements into_group_map_by
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.
Oh, it's one of those things that adds magic behind the scenes. Still getting used to that.