mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Fixed test block conditions (#3332)
This commit is contained in:
committed by
Bastian Köcher
parent
58bd0d4c05
commit
c0fd256c01
@@ -442,6 +442,11 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
self.sync.status().num_peers
|
||||
}
|
||||
|
||||
/// Number of blocks in the import queue.
|
||||
pub fn num_queued_blocks(&self) -> u32 {
|
||||
self.sync.status().queued_blocks
|
||||
}
|
||||
|
||||
/// Starts a new data demand request.
|
||||
///
|
||||
/// The parameter contains a `Sender` where the result, once received, must be sent.
|
||||
|
||||
@@ -198,7 +198,9 @@ pub struct Status<B: BlockT> {
|
||||
/// Target sync block number.
|
||||
pub best_seen_block: Option<NumberFor<B>>,
|
||||
/// Number of peers participating in syncing.
|
||||
pub num_peers: u32
|
||||
pub num_peers: u32,
|
||||
/// Number of blocks queued for import
|
||||
pub queued_blocks: u32,
|
||||
}
|
||||
|
||||
/// A peer did not behave as expected and should be reported.
|
||||
@@ -317,7 +319,8 @@ impl<B: BlockT> ChainSync<B> {
|
||||
Status {
|
||||
state: sync_state,
|
||||
best_seen_block: best_seen,
|
||||
num_peers: self.peers.len() as u32
|
||||
num_peers: self.peers.len() as u32,
|
||||
queued_blocks: self.queue_blocks.len() as u32,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,11 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkWorker
|
||||
self.network_service.user_protocol().num_sync_peers()
|
||||
}
|
||||
|
||||
/// Number of blocks in the import queue.
|
||||
pub fn num_queued_blocks(&self) -> u32 {
|
||||
self.network_service.user_protocol().num_queued_blocks()
|
||||
}
|
||||
|
||||
/// Adds an address for a node.
|
||||
pub fn add_known_address(&mut self, peer_id: PeerId, addr: Multiaddr) {
|
||||
self.network_service.add_known_address(peer_id, addr);
|
||||
|
||||
@@ -591,6 +591,9 @@ pub trait TestNetFactory: Sized {
|
||||
// Return `NotReady` if there's a mismatch in the highest block number.
|
||||
let mut highest = None;
|
||||
for peer in self.peers().iter() {
|
||||
if peer.is_major_syncing() || peer.network.num_queued_blocks() != 0 {
|
||||
return Async::NotReady
|
||||
}
|
||||
match (highest, peer.client.info().chain.best_number) {
|
||||
(None, b) => highest = Some(b),
|
||||
(Some(ref a), ref b) if a == b => {},
|
||||
|
||||
Reference in New Issue
Block a user