Renaming status fields to something more descriptive.
This commit is contained in:
parent
884f2dd873
commit
e1c3ab1846
@ -42,7 +42,7 @@
|
|||||||
//!
|
//!
|
||||||
//! let miner: Miner = Miner::default();
|
//! let miner: Miner = Miner::default();
|
||||||
//! // get status
|
//! // get status
|
||||||
//! assert_eq!(miner.status().transaction_queue_pending, 0);
|
//! assert_eq!(miner.status().transactions_in_pending_queue, 0);
|
||||||
//!
|
//!
|
||||||
//! // Check block for sealing
|
//! // Check block for sealing
|
||||||
//! miner.prepare_sealing(client.deref());
|
//! miner.prepare_sealing(client.deref());
|
||||||
@ -105,9 +105,9 @@ pub trait MinerService : Send + Sync {
|
|||||||
/// Mining status
|
/// Mining status
|
||||||
pub struct MinerStatus {
|
pub struct MinerStatus {
|
||||||
/// Number of transactions in queue with state `pending` (ready to be included in block)
|
/// Number of transactions in queue with state `pending` (ready to be included in block)
|
||||||
pub transaction_queue_pending: usize,
|
pub transactions_in_pending_queue: usize,
|
||||||
/// Number of transactions in queue with state `future` (not yet ready to be included in block)
|
/// Number of transactions in queue with state `future` (not yet ready to be included in block)
|
||||||
pub transaction_queue_future: usize,
|
pub transactions_in_future_queue: usize,
|
||||||
/// Number of transactions included in currently mined block
|
/// Number of transactions included in currently mined block
|
||||||
pub block_pending: usize,
|
pub transactions_in_pending_block: usize,
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,9 @@ impl MinerService for Miner {
|
|||||||
let status = self.transaction_queue.lock().unwrap().status();
|
let status = self.transaction_queue.lock().unwrap().status();
|
||||||
let block = self.sealing_block.lock().unwrap();
|
let block = self.sealing_block.lock().unwrap();
|
||||||
MinerStatus {
|
MinerStatus {
|
||||||
transaction_queue_pending: status.pending,
|
transactions_in_pending_queue: status.pending,
|
||||||
transaction_queue_future: status.future,
|
transactions_in_future_queue: status.future,
|
||||||
block_pending: block.as_ref().map_or(0, |b| b.transactions().len()),
|
transactions_in_pending_block: block.as_ref().map_or(0, |b| b.transactions().len()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,9 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
fn block_transaction_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
fn block_transaction_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
||||||
from_params::<(BlockNumber,)>(params)
|
from_params::<(BlockNumber,)>(params)
|
||||||
.and_then(|(block_number,)| match block_number {
|
.and_then(|(block_number,)| match block_number {
|
||||||
BlockNumber::Pending => to_value(&U256::from(take_weak!(self.miner).status().block_pending)),
|
BlockNumber::Pending =>to_value(
|
||||||
|
&U256::from(take_weak!(self.miner).status().transactions_in_pending_block)
|
||||||
|
),
|
||||||
_ => to_value(&take_weak!(self.client).block(block_number.into())
|
_ => to_value(&take_weak!(self.client).block(block_number.into())
|
||||||
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).transactions_count())))
|
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).transactions_count())))
|
||||||
})
|
})
|
||||||
|
@ -29,9 +29,9 @@ impl MinerService for TestMinerService {
|
|||||||
/// Returns miner's status.
|
/// Returns miner's status.
|
||||||
fn status(&self) -> MinerStatus {
|
fn status(&self) -> MinerStatus {
|
||||||
MinerStatus {
|
MinerStatus {
|
||||||
transaction_queue_pending: 0,
|
transactions_in_pending_queue: 0,
|
||||||
transaction_queue_future: 0,
|
transactions_in_future_queue: 0,
|
||||||
block_pending: 1
|
transactions_in_pending_block: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ impl ChainSync {
|
|||||||
self.remove_downloaded_blocks(number + 1);
|
self.remove_downloaded_blocks(number + 1);
|
||||||
}
|
}
|
||||||
if self.have_common_block && number < self.current_base_block() + 1 {
|
if self.have_common_block && number < self.current_base_block() + 1 {
|
||||||
// unkown header
|
// unkown header
|
||||||
debug!(target: "sync", "Old block header {:?} ({}) is unknown, restarting sync", hash, number);
|
debug!(target: "sync", "Old block header {:?} ({}) is unknown, restarting sync", hash, number);
|
||||||
self.restart(io);
|
self.restart(io);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -1633,14 +1633,14 @@ mod tests {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
sync.chain_new_blocks(&mut io, &[], &[], &[], &good_blocks);
|
sync.chain_new_blocks(&mut io, &[], &[], &[], &good_blocks);
|
||||||
assert_eq!(sync.miner.status().transaction_queue_future, 0);
|
assert_eq!(sync.miner.status().transactions_in_future_queue, 0);
|
||||||
assert_eq!(sync.miner.status().transaction_queue_pending, 1);
|
assert_eq!(sync.miner.status().transactions_in_pending_queue, 1);
|
||||||
sync.chain_new_blocks(&mut io, &good_blocks, &[], &[], &retracted_blocks);
|
sync.chain_new_blocks(&mut io, &good_blocks, &[], &[], &retracted_blocks);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
let status = sync.miner.status();
|
let status = sync.miner.status();
|
||||||
assert_eq!(status.transaction_queue_pending, 1);
|
assert_eq!(status.transactions_in_pending_queue, 1);
|
||||||
assert_eq!(status.transaction_queue_future, 0);
|
assert_eq!(status.transactions_in_future_queue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user