mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Update to Substrate master (#176)
* Update to master This introduces a new type `CollatorId`, currently just `SessionKey` but which would forseeably change to its own thing. It seems to work like this (despite there being a lot of the new-incompatible `AccountId` replaced). No idea if it does anything sensible, though. * Cleanups * Fix tests * Remove commented code * Specify commit hash * Remove commented code * Correct version * Update runtime/Cargo.toml Co-Authored-By: gavofyork <github@gavwood.com> * PairT instead of _Pair * Update lock file * Remove rev causing upset
This commit is contained in:
@@ -58,7 +58,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
Vec::new()
|
||||
}
|
||||
Role::Primary => {
|
||||
let new_primary = self.primary_for.insert(key);
|
||||
let new_primary = self.primary_for.insert(key.clone());
|
||||
if new_primary {
|
||||
self.collations_targeting(&key)
|
||||
} else {
|
||||
@@ -72,7 +72,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
/// to the validator.
|
||||
pub fn fresh_key(&mut self, old_key: &SessionKey, new_key: &SessionKey) -> Vec<(Hash, C)> {
|
||||
if self.primary_for.remove(old_key) {
|
||||
self.primary_for.insert(*new_key);
|
||||
self.primary_for.insert(new_key.clone());
|
||||
|
||||
self.collations_targeting(new_key)
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
let borrowed_collation = &local.collation;
|
||||
local.targets
|
||||
.intersection(&self.primary_for)
|
||||
.map(move |k| (*k, borrowed_collation.clone()))
|
||||
.map(move |k| (k.clone(), borrowed_collation.clone()))
|
||||
}
|
||||
|
||||
fn collations_targeting(&self, key: &SessionKey) -> Vec<(Hash, C)> {
|
||||
@@ -130,14 +130,16 @@ impl<C: Clone> LocalCollations<C> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use substrate_primitives::crypto::UncheckedInto;
|
||||
use polkadot_primitives::parachain::ValidatorId;
|
||||
|
||||
#[test]
|
||||
fn add_validator_with_ready_collation() {
|
||||
let key = [1; 32].into();
|
||||
let key: ValidatorId = [1; 32].unchecked_into();
|
||||
let relay_parent = [2; 32].into();
|
||||
let targets = {
|
||||
let mut set = HashSet::new();
|
||||
set.insert(key);
|
||||
set.insert(key.clone());
|
||||
set
|
||||
};
|
||||
|
||||
@@ -148,18 +150,18 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn rename_with_ready() {
|
||||
let orig_key = [1; 32].into();
|
||||
let new_key = [2; 32].into();
|
||||
let orig_key: ValidatorId = [1; 32].unchecked_into();
|
||||
let new_key: ValidatorId = [2; 32].unchecked_into();
|
||||
let relay_parent = [255; 32].into();
|
||||
let targets = {
|
||||
let mut set = HashSet::new();
|
||||
set.insert(new_key);
|
||||
set.insert(new_key.clone());
|
||||
set
|
||||
};
|
||||
|
||||
let mut tracker: LocalCollations<u8> = LocalCollations::new();
|
||||
assert!(tracker.add_collation(relay_parent, targets, 5).next().is_none());
|
||||
assert!(tracker.note_validator_role(orig_key, Role::Primary).is_empty());
|
||||
assert!(tracker.note_validator_role(orig_key.clone(), Role::Primary).is_empty());
|
||||
assert_eq!(tracker.fresh_key(&orig_key, &new_key), vec![(relay_parent, 5u8)]);
|
||||
}
|
||||
|
||||
@@ -183,16 +185,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn add_collation_with_connected_target() {
|
||||
let key = [1; 32].into();
|
||||
let key: ValidatorId = [1; 32].unchecked_into();
|
||||
let relay_parent = [2; 32].into();
|
||||
let targets = {
|
||||
let mut set = HashSet::new();
|
||||
set.insert(key);
|
||||
set.insert(key.clone());
|
||||
set
|
||||
};
|
||||
|
||||
let mut tracker = LocalCollations::new();
|
||||
assert!(tracker.note_validator_role(key, Role::Primary).is_empty());
|
||||
assert!(tracker.note_validator_role(key.clone(), Role::Primary).is_empty());
|
||||
assert_eq!(tracker.add_collation(relay_parent, targets, 5).next(), Some((key, 5)));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user