mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Update to latest Substrate master. (#353)
* Integrate srml/im-online * Fix all build errors with old aura. * Fix most of the build errors. * Builds and tests seem to pass (I will not trust this commit yet) * Apply suggestions from code review Co-Authored-By: Robert Habermeier <rphmeier@gmail.com> * Kill some warnings. * fix panics on 0 validators * Fix dev chain. * Fix author stuff * fix im online integration. * Some tweaks * Introduce app-crypto * Initial build work * codec update / tweaks * patch polkadot-erasure-coding input * More fixes for new crypto * More fixes * Update parachains module * evamp parachain crypto * More crypto work. * Chain spec and service. * ChainSpec stuff * Last bits for a clean build * Tweak coment * adapt polkadot-validation to the new keystore * polkadot-network compiles, but tests don't * Integrate the new parachain validation stuff * delete message_routing file * make polkadot-network tests compile and pass * runtime tests compile and pass * update substrate ref * service compiles * all tests pass * Add TODO, change branch back to polkadot-master * Lock file * TODOs done * Issue number * Remove old tODO * Remove commented code
This commit is contained in:
@@ -19,24 +19,22 @@
|
||||
//! Collations are attempted to be repropagated when a new validator connects,
|
||||
//! a validator changes his session key, or when they are generated.
|
||||
|
||||
use polkadot_primitives::{Hash, SessionKey};
|
||||
|
||||
use polkadot_primitives::{Hash, parachain::{ValidatorId}};
|
||||
use crate::collator_pool::Role;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const LIVE_FOR: Duration = Duration::from_secs(60 * 5);
|
||||
|
||||
struct LocalCollation<C> {
|
||||
targets: HashSet<SessionKey>,
|
||||
targets: HashSet<ValidatorId>,
|
||||
collation: C,
|
||||
live_since: Instant,
|
||||
}
|
||||
|
||||
/// Tracker for locally collated values and which validators to send them to.
|
||||
pub struct LocalCollations<C> {
|
||||
primary_for: HashSet<SessionKey>,
|
||||
primary_for: HashSet<ValidatorId>,
|
||||
local_collations: HashMap<Hash, LocalCollation<C>>,
|
||||
}
|
||||
|
||||
@@ -51,7 +49,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
|
||||
/// Validator gave us a new role. If the new role is "primary", this function might return
|
||||
/// a set of collations to send to that validator.
|
||||
pub fn note_validator_role(&mut self, key: SessionKey, role: Role) -> Vec<(Hash, C)> {
|
||||
pub fn note_validator_role(&mut self, key: ValidatorId, role: Role) -> Vec<(Hash, C)> {
|
||||
match role {
|
||||
Role::Backup => {
|
||||
self.primary_for.remove(&key);
|
||||
@@ -70,7 +68,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
|
||||
/// Fresh session key from a validator. Returns a vector of collations to send
|
||||
/// to the validator.
|
||||
pub fn fresh_key(&mut self, old_key: &SessionKey, new_key: &SessionKey) -> Vec<(Hash, C)> {
|
||||
pub fn fresh_key(&mut self, old_key: &ValidatorId, new_key: &ValidatorId) -> Vec<(Hash, C)> {
|
||||
if self.primary_for.remove(old_key) {
|
||||
self.primary_for.insert(new_key.clone());
|
||||
|
||||
@@ -81,7 +79,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
}
|
||||
|
||||
/// Validator disconnected.
|
||||
pub fn on_disconnect(&mut self, key: &SessionKey) {
|
||||
pub fn on_disconnect(&mut self, key: &ValidatorId) {
|
||||
self.primary_for.remove(key);
|
||||
}
|
||||
|
||||
@@ -99,10 +97,10 @@ impl<C: Clone> LocalCollations<C> {
|
||||
pub fn add_collation<'a>(
|
||||
&'a mut self,
|
||||
relay_parent: Hash,
|
||||
targets: HashSet<SessionKey>,
|
||||
targets: HashSet<ValidatorId>,
|
||||
collation: C
|
||||
)
|
||||
-> impl Iterator<Item=(SessionKey, C)> + 'a
|
||||
-> impl Iterator<Item=(ValidatorId, C)> + 'a
|
||||
{
|
||||
self.local_collations.insert(relay_parent, LocalCollation {
|
||||
targets,
|
||||
@@ -119,7 +117,7 @@ impl<C: Clone> LocalCollations<C> {
|
||||
.map(move |k| (k.clone(), borrowed_collation.clone()))
|
||||
}
|
||||
|
||||
fn collations_targeting(&self, key: &SessionKey) -> Vec<(Hash, C)> {
|
||||
fn collations_targeting(&self, key: &ValidatorId) -> Vec<(Hash, C)> {
|
||||
self.local_collations.iter()
|
||||
.filter(|&(_, ref v)| v.targets.contains(key))
|
||||
.map(|(h, v)| (*h, v.collation.clone()))
|
||||
|
||||
Reference in New Issue
Block a user