refactoring of report functions, some comments
This commit is contained in:
parent
deffb271bc
commit
3dd220b62f
@ -30,16 +30,12 @@ use client::BlockStatus;
|
|||||||
/// Block queue status
|
/// Block queue status
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BlockQueueInfo {
|
pub struct BlockQueueInfo {
|
||||||
/// Indicates that queue is full
|
|
||||||
pub full: bool,
|
|
||||||
/// Number of queued blocks pending verification
|
/// Number of queued blocks pending verification
|
||||||
pub unverified_queue_size: usize,
|
pub unverified_queue_size: usize,
|
||||||
/// Number of verified queued blocks pending import
|
/// Number of verified queued blocks pending import
|
||||||
pub verified_queue_size: usize,
|
pub verified_queue_size: usize,
|
||||||
/// Number of blocks being verified
|
/// Number of blocks being verified
|
||||||
pub verifying_queue_size: usize,
|
pub verifying_queue_size: usize,
|
||||||
/// Indicates queue is empty
|
|
||||||
pub empty: bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockQueueInfo {
|
impl BlockQueueInfo {
|
||||||
@ -48,6 +44,16 @@ impl BlockQueueInfo {
|
|||||||
|
|
||||||
/// The size of the unverified and verifying queues.
|
/// The size of the unverified and verifying queues.
|
||||||
pub fn incomplete_queue_size(&self) -> usize { self.unverified_queue_size + self.verifying_queue_size }
|
pub fn incomplete_queue_size(&self) -> usize { self.unverified_queue_size + self.verifying_queue_size }
|
||||||
|
|
||||||
|
/// Indicates that queue is full
|
||||||
|
pub fn is_full(&self) -> bool {
|
||||||
|
self.unverified_queue_size + self.verified_queue_size + self.verifying_queue_size > MAX_UNVERIFIED_QUEUE_SIZE
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Indicates that queue is empty
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.unverified_queue_size + self.verified_queue_size + self.verifying_queue_size == 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A queue of blocks. Sits between network or other I/O and the BlockChain.
|
/// A queue of blocks. Sits between network or other I/O and the BlockChain.
|
||||||
@ -311,11 +317,9 @@ impl BlockQueue {
|
|||||||
pub fn queue_info(&self) -> BlockQueueInfo {
|
pub fn queue_info(&self) -> BlockQueueInfo {
|
||||||
let verification = self.verification.lock().unwrap();
|
let verification = self.verification.lock().unwrap();
|
||||||
BlockQueueInfo {
|
BlockQueueInfo {
|
||||||
full: verification.unverified.len() + verification.verifying.len() + verification.verified.len() >= MAX_UNVERIFIED_QUEUE_SIZE,
|
|
||||||
verified_queue_size: verification.verified.len(),
|
verified_queue_size: verification.verified.len(),
|
||||||
unverified_queue_size: verification.unverified.len(),
|
unverified_queue_size: verification.unverified.len(),
|
||||||
verifying_queue_size: verification.verifying.len(),
|
verifying_queue_size: verification.verifying.len(),
|
||||||
empty: verification.verified.is_empty() && verification.unverified.is_empty() && verification.verifying.is_empty(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ impl Client {
|
|||||||
trace!(target: "client", "Imported #{} ({})", header.number(), header.hash());
|
trace!(target: "client", "Imported #{} ({})", header.number(), header.hash());
|
||||||
ret += 1;
|
ret += 1;
|
||||||
|
|
||||||
if self.block_queue.read().unwrap().queue_info().empty {
|
if self.block_queue.read().unwrap().queue_info().is_empty() {
|
||||||
io.send(NetworkIoMessage::User(SyncMessage::BlockVerified)).unwrap();
|
io.send(NetworkIoMessage::User(SyncMessage::BlockVerified)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user