Skip to content
Open
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
13 changes: 11 additions & 2 deletions smart-contracts/ink/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ mod allways_swap_manager {
};
let votes = self.record_vote(id, caller)?;
if votes >= self.get_required_votes() {
on_quorum(self)?;
// Clear the request whether on_quorum succeeds or fails.
// Without this, a closure that returns Err leaves the vote
// persisted on a request that won't be cleared until expiry,
// blocking the validator from re-voting (AlreadyVoted).
let result = on_quorum(self);
self.clear_request(miner, req_type);
result?;
}
Ok(())
}
Expand Down Expand Up @@ -280,9 +285,13 @@ mod allways_swap_manager {
});

if votes >= self.get_required_votes() {
on_quorum(self)?;
// Clear on success or failure so a failed quorum doesn't
// strand the vote (AlreadyVoted blocks the validator from
// retrying until the request expires).
let result = on_quorum(self);
self.clear_request_data(id);
self.pending_swap_votes.remove((swap_id, req_type));
result?;
}
Ok(())
}
Expand Down