mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Use a more typesafe approach for managing indexed data (#6150)
* Fix for issue #2403 * Nightly fmt * Quick documentation fixes * Default Implementation * iter() function integrated * Implemented iter functionalities * Fmt * small change * updates node-network * updates in dispute-coordinator * Updates * benchmarking fix * minor fix * test fixes in runtime api * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * Removal of [index], shorting of FromIterator, Renaming of GroupValidators to ValidatorGroups * Removal of ops import * documentation fixes for spell check * implementation of generic type * Refactoring * Test and documentation fixes * minor test fix * minor test fix * minor test fix * Update node/network/statement-distribution/src/lib.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * removed IterMut * Update node/core/dispute-coordinator/src/import.rs Co-authored-by: Andronik <write@reusable.software> * Update node/core/dispute-coordinator/src/initialized.rs Co-authored-by: Andronik <write@reusable.software> * Update primitives/src/v2/mod.rs Co-authored-by: Andronik <write@reusable.software> * fmt * IterMut * documentation update Co-authored-by: Andronik <write@reusable.software> * minor adjustments and new TypeIndex trait * spelling fix * TypeIndex fix Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
@@ -27,9 +27,9 @@ use sp_keystore::{CryptoStore, SyncCryptoStorePtr};
|
||||
|
||||
use polkadot_node_subsystem::{messages::RuntimeApiMessage, overseer, SubsystemSender};
|
||||
use polkadot_primitives::v2::{
|
||||
CandidateEvent, CoreState, EncodeAs, GroupIndex, GroupRotationInfo, Hash, OccupiedCore,
|
||||
ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed, SigningContext, UncheckedSigned,
|
||||
ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
|
||||
CandidateEvent, CoreState, EncodeAs, GroupIndex, GroupRotationInfo, Hash, IndexedVec,
|
||||
OccupiedCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed, SigningContext,
|
||||
UncheckedSigned, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -228,7 +228,10 @@ impl RuntimeInfo {
|
||||
/// Get our `ValidatorIndex`.
|
||||
///
|
||||
/// Returns: None if we are not a validator.
|
||||
async fn get_our_index(&self, validators: &[ValidatorId]) -> Option<ValidatorIndex> {
|
||||
async fn get_our_index(
|
||||
&self,
|
||||
validators: &IndexedVec<ValidatorIndex, ValidatorId>,
|
||||
) -> Option<ValidatorIndex> {
|
||||
let keystore = self.keystore.as_ref()?;
|
||||
for (i, v) in validators.iter().enumerate() {
|
||||
if CryptoStore::has_keys(&**keystore, &[(v.to_raw_vec(), ValidatorId::ID)]).await {
|
||||
@@ -254,7 +257,7 @@ where
|
||||
|
||||
session_info
|
||||
.validators
|
||||
.get(signed.unchecked_validator_index().0 as usize)
|
||||
.get(signed.unchecked_validator_index())
|
||||
.ok_or_else(|| signed.clone())
|
||||
.and_then(|v| signed.try_into_checked(&signing_context, v))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user