Infrastructure improvements (#2897)

* Factor out runtime module into utils.

* Add maybe_authority information to `PeerConnected` event.

We already gather this information in authority discovery, so we might
as well share it with others.

This opens up an easy path to trigger validators differently from normal
nodes, e.g. for prioritization. This change has become more important
now, that we just connect to all validators and therefore just have a
long peer list without any information about those nodes.

* Test fix.
This commit is contained in:
Robert Klotzner
2021-04-16 21:42:20 +02:00
committed by GitHub
parent 23db3479a0
commit dacde443f7
19 changed files with 175 additions and 76 deletions
@@ -33,8 +33,9 @@ use polkadot_subsystem::{
ActiveLeavesUpdate, SubsystemContext, ActivatedLeaf,
messages::{AllMessages, NetworkBridgeMessage, IfDisconnected}
};
use polkadot_node_subsystem_util::runtime::{Runtime, ValidatorInfo};
use crate::{error::{Error, log_error}, runtime::{Runtime, ValidatorInfo}};
use crate::error::{Error, log_error};
/// Number of sessions we want to keep in the LRU.
const NUM_SESSIONS: usize = 2;
@@ -274,7 +275,7 @@ mod tests {
let (mut context, mut virtual_overseer) =
test_helpers::make_subsystem_context::<AvailabilityDistributionMessage, TaskExecutor>(pool.clone());
let keystore = make_ferdie_keystore();
let mut runtime = crate::runtime::Runtime::new(keystore);
let mut runtime = polkadot_node_subsystem_util::runtime::Runtime::new(keystore);
let (tx, rx) = oneshot::channel();
let testee = async {