Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs committed Oct 24, 2024
1 parent 705fc87 commit 58eeb31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ macro_rules! generate_electoral_system_tuple_impls {
properties: $current::ElectionProperties,
) -> Result<(), CorruptStorageError> {
StorageAccess::refresh_election(
// The current election id + extra that we want to refresh.
self.id.with_extra(CompositeElectionIdentifierExtra::$current(*self.id.extra())),
// The new extra we want to use.
CompositeElectionIdentifierExtra::$current(new_extra),
CompositeElectionProperties::$current(properties),
)?;
Expand Down Expand Up @@ -424,7 +426,7 @@ macro_rules! generate_electoral_system_tuple_impls {
state: $current::ElectionState,
) -> Result<Self::ElectionWriteAccess, CorruptStorageError> {
let election_identifier = StorageAccess::new_election(CompositeElectionIdentifierExtra::$current(extra), CompositeElectionProperties::$current(properties), CompositeElectionState::$current(state))?;
Ok(Self::ElectionWriteAccess::new(election_identifier.with_extra(extra)))
Ok(Self::election_mut(election_identifier.with_extra(extra)))
}

fn election_mut(
Expand Down
15 changes: 6 additions & 9 deletions state-chain/pallets/cf-elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,10 @@ pub mod pallet {
} else {
ElectionProperties::<T, I>::remove(election_identifier);
let new_election_identifier =
ElectionIdentifier::new(*election_identifier.unique_monotonic(), new_extra);
CompositeElectionIdentifierOf::<Self::ElectoralSystemRunner>::new(
*election_identifier.unique_monotonic(),
new_extra,
);
ElectionProperties::<T, I>::insert(new_election_identifier, properties);
Ok(())
}
Expand Down Expand Up @@ -775,8 +778,8 @@ pub mod pallet {
Ok(SharedData::<T, I>::get(shared_data_hash))
}) {
// Only a full vote can count towards consensus.
Ok(Some((properties, AuthorityVote::Vote(vote)))) => Ok(Some((properties,
vote))), Ok(Some((_properties, AuthorityVote::PartialVote(_)))) => Ok(None),
Ok(Some((properties, AuthorityVote::Vote(vote)))) => Ok(Some((properties, vote))),
Ok(Some((_properties, AuthorityVote::PartialVote(_)))) => Ok(None),
Ok(None) => Ok(None),
Err(e) => Err(e),
}
Expand Down Expand Up @@ -1224,8 +1227,6 @@ pub mod pallet {
ConstU32<MAXIMUM_VOTES_PER_EXTRINSIC>,
>,
) -> DispatchResult {
Self::ensure_initialized()?;

let (epoch_index, authority, authority_index) = Self::ensure_can_vote(origin)?;

ensure!(!authority_votes.is_empty(), Error::<T, I>::NoVotesSpecified);
Expand Down Expand Up @@ -1673,10 +1674,6 @@ pub mod pallet {
Ok(())
}

pub fn ensure_initialized() -> Result<(), DispatchError> {
Self::with_status_check(|| Ok(()))
}

/// Provides access into the ElectoralSystem's current election
/// identifiers.
pub fn with_election_identifiers<
Expand Down

0 comments on commit 58eeb31

Please sign in to comment.