-
Notifications
You must be signed in to change notification settings - Fork 15
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
Divide logic between enum variants #5488
Conversation
ChainProgress::Reorg(reorg_range) => { | ||
// Delete any elections that are ongoing for any blocks in the reorg range. | ||
for (i, election_identifier) in election_identifiers.into_iter().enumerate() { | ||
let election = ElectoralAccess::election_mut(election_identifier); | ||
let properties = election.properties()?; | ||
if properties.0.into_range_inclusive() == *reorg_range { | ||
election.delete(); | ||
open_elections = open_elections.saturating_sub(1); | ||
remaining_election_identifiers.remove(i); | ||
} | ||
} |
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.
Actually, when I detect a reorg, I have two ranges: removed
and added
. Depending on circumstances either one could be "longer" then the other. removed
are the headers which I have previously witnessed and forwarded to you and are now invalid due to the reorg, added
are the replacement headers now valid after the reorg.
It seems to me that since you want to delete the previously created elections, and recreate elections for the new blocks, you actually want to get both ranges. So I propose to change the variant to be ChainProgress::Reorg { removed_range: InclusiveRange<>, added_range: InclusiveRange<> }
state-chain/pallets/cf-elections/src/electoral_systems/block_witnesser.rs
Show resolved
Hide resolved
* wip * divide logic between enum variants
* wip * divide logic between enum variants
No description provided.