-
Notifications
You must be signed in to change notification settings - Fork 11
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
chore: simplify fn prune_messages_to_be_saved #414
base: develop
Are you sure you want to change the base?
chore: simplify fn prune_messages_to_be_saved #414
Conversation
ab9c88a
to
1a2ff8f
Compare
} | ||
} | ||
let mut sorted_messages = complete_messages.into_iter().collect::<Vec<_>>(); | ||
sorted_messages.sort_unstable(); |
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.
This seems to use the Ord implementation of BroadcastMessageWithTimestamp, which will sort messages according to their timestamp. It is possible that the timestamp of ChannelUpdate is smaller than that of Channel announcement (we didn't have code to specifically make the timestamp of ChannelUpdate later than the timestamp of the funding transaction block, we just use the system time).
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.
will order by message_id first:
Lines 2435 to 2441 in 1a2ff8f
impl Ord for BroadcastMessageWithTimestamp { | |
fn cmp(&self, other: &Self) -> Ordering { | |
self.message_id() | |
.cmp(&other.message_id()) | |
.then(self.timestamp().cmp(&other.timestamp())) | |
} | |
} |
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.
Sorry. I didn't look carefully. In that case, this PR LGTM. I created a few tests for the dependency of channel gossip messages in #418 . Can you take a look and check if the code change here does not break the tests (I believe it doesn't. Still, it is better to
have some tests)?
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.
rebased and pushed
1a2ff8f
to
c950ba1
Compare
The current implementation of prune_messages_to_be_saved is complex and unintuitive, it can be implemented in a much simpler way.