-
Notifications
You must be signed in to change notification settings - Fork 712
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
Fix async message updates and add unit test #4766
base: mainnet_2_3
Are you sure you want to change the base?
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.
Great work! The various tested scenarios are nice
@@ -83,7 +83,9 @@ impl ActiveHistory { | |||
return HistorySearchResult::Present(SetUpdateOrDelete::Set(msg)); | |||
} | |||
Some(SetUpdateOrDelete::Update(msg_update)) => { | |||
current_updates.apply(msg_update.clone()); | |||
let mut combined_message_update = msg_update.clone(); |
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 think current_updates does not need to be mut anymore
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 think it still does because of line 88 :)
current_updates.apply(msg_update.clone()); | ||
let mut combined_message_update = msg_update.clone(); | ||
combined_message_update.apply(current_updates); | ||
current_updates = combined_message_update; | ||
} | ||
Some(SetUpdateOrDelete::Delete) => return HistorySearchResult::Absent, |
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.
how about this ? if the current_updates
actually creates an element while it was deleted before... can it happen?
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.
- If we Delete then Set, the latest Set is taken into account and we break before
- If we Delete then Update, I don't think it's possible. If it happens it's ok to return Absent in my mind, but it would be a bug no?
@@ -287,7 +287,7 @@ impl SpeculativeAsyncPool { | |||
} | |||
Present(SetUpdateOrDelete::Update(msg_update)) => { | |||
current_changes.entry(message_id).and_modify(|e| { | |||
e.apply(msg_update.clone()); | |||
*e = msg_update.clone(); |
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 was this changed ?
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 work before, but it technically applied the current_changes twice (the returned msg_update already took them into account, so we directly replace it)
@sydhds unless you think otherwise, I think we can merge this one :) |
No description provided.