Skip to content
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 web server #1839

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/web_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@ impl<KEY: SignatureKey> WebServerDataSource<KEY> for WebServerState<KEY> {
.or_insert_with(|| vec![(*highest_index, vote)]);
self.view_sync_vote_index
.entry(view_number)
.and_modify(|index| *index += 1);
.and_modify(|index| {
// Update the index if it's not just added.
if *index > 0 {
*index += 1
}
});
Ok(())
}
/// Stores a received proposal in the `WebServerState`
Expand Down Expand Up @@ -349,7 +354,8 @@ impl<KEY: SignatureKey> WebServerDataSource<KEY> for WebServerState<KEY> {
) -> Result<(), Error> {
// Only keep proposal history for MAX_VIEWS number of view
if self.view_sync_proposals.len() >= MAX_VIEWS {
self.view_sync_proposals.remove(&self.oldest_view_sync_vote);
self.view_sync_proposals
.remove(&self.oldest_view_sync_proposal);
while !self
.view_sync_proposals
.contains_key(&self.oldest_view_sync_proposal)
Expand All @@ -367,7 +373,12 @@ impl<KEY: SignatureKey> WebServerDataSource<KEY> for WebServerState<KEY> {
.or_insert_with(|| vec![(*highest_index, proposal)]);
self.view_sync_proposal_index
.entry(view_number)
.and_modify(|index| *index += 1);
.and_modify(|index| {
// Update the index if it's not just added.
if *index > 0 {
*index += 1
}
});
Ok(())
}

Expand Down
Loading