mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 05:21:03 +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:
@@ -58,7 +58,7 @@ use polkadot_node_subsystem::{
|
||||
use polkadot_node_subsystem_util::request_session_info;
|
||||
use polkadot_primitives::v2::{
|
||||
AuthorityDiscoveryId, BlakeTwo256, BlockNumber, CandidateHash, CandidateReceipt, GroupIndex,
|
||||
Hash, HashT, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
|
||||
Hash, HashT, IndexedVec, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
|
||||
};
|
||||
|
||||
mod error;
|
||||
@@ -134,7 +134,7 @@ struct RecoveryParams {
|
||||
validator_authority_keys: Vec<AuthorityDiscoveryId>,
|
||||
|
||||
/// Validators relevant to this `RecoveryTask`.
|
||||
validators: Vec<ValidatorId>,
|
||||
validators: IndexedVec<ValidatorIndex, ValidatorId>,
|
||||
|
||||
/// The number of pieces needed.
|
||||
threshold: usize,
|
||||
@@ -871,7 +871,7 @@ async fn launch_recovery_task<Context>(
|
||||
};
|
||||
|
||||
let phase = backing_group
|
||||
.and_then(|g| session_info.validator_groups.get(g.0 as usize))
|
||||
.and_then(|g| session_info.validator_groups.get(g))
|
||||
.map(|group| Source::RequestFromBackers(RequestFromBackers::new(group.clone())))
|
||||
.unwrap_or_else(|| {
|
||||
Source::RequestChunks(RequestChunksFromValidators::new(params.validators.len() as _))
|
||||
|
||||
@@ -36,7 +36,9 @@ use polkadot_node_subsystem::{
|
||||
};
|
||||
use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle};
|
||||
use polkadot_node_subsystem_util::TimeoutExt;
|
||||
use polkadot_primitives::v2::{AuthorityDiscoveryId, Hash, HeadData, PersistedValidationData};
|
||||
use polkadot_primitives::v2::{
|
||||
AuthorityDiscoveryId, Hash, HeadData, IndexedVec, PersistedValidationData, ValidatorId,
|
||||
};
|
||||
use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_hash};
|
||||
|
||||
type VirtualOverseer = TestSubsystemContextHandle<AvailabilityRecoveryMessage>;
|
||||
@@ -179,7 +181,7 @@ impl Has {
|
||||
#[derive(Clone)]
|
||||
struct TestState {
|
||||
validators: Vec<Sr25519Keyring>,
|
||||
validator_public: Vec<ValidatorId>,
|
||||
validator_public: IndexedVec<ValidatorIndex, ValidatorId>,
|
||||
validator_authority_id: Vec<AuthorityDiscoveryId>,
|
||||
current: Hash,
|
||||
candidate: CandidateReceipt,
|
||||
@@ -218,7 +220,7 @@ impl TestState {
|
||||
validators: self.validator_public.clone(),
|
||||
discovery_keys: self.validator_authority_id.clone(),
|
||||
// all validators in the same group.
|
||||
validator_groups: vec![(0..self.validators.len()).map(|i| ValidatorIndex(i as _)).collect()],
|
||||
validator_groups: IndexedVec::<GroupIndex,Vec<ValidatorIndex>>::from(vec![(0..self.validators.len()).map(|i| ValidatorIndex(i as _)).collect()]),
|
||||
assignment_keys: vec![],
|
||||
n_cores: 0,
|
||||
zeroth_delay_tranche_width: 0,
|
||||
@@ -402,7 +404,7 @@ impl TestState {
|
||||
}
|
||||
}
|
||||
|
||||
fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> Vec<ValidatorId> {
|
||||
fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> IndexedVec<ValidatorIndex, ValidatorId> {
|
||||
val_ids.iter().map(|v| v.public().into()).collect()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user