improve logging when receiving blocks and txs (msg_len) (#1383)

* better logging for msg_len and # kernels

* rustfmt
This commit is contained in:
Antioch Peverell 2018-08-19 18:15:42 +01:00 committed by GitHub
parent 7d677737d7
commit 5abefbff33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 30 deletions

View file

@ -148,7 +148,8 @@ impl OutputHandler {
.filter(|output| commitments.is_empty() || commitments.contains(&output.commit)) .filter(|output| commitments.is_empty() || commitments.contains(&output.commit))
.map(|output| { .map(|output| {
OutputPrintable::from_output(output, w(&self.chain), Some(&header), include_proof) OutputPrintable::from_output(output, w(&self.chain), Some(&header), include_proof)
}).collect(); })
.collect();
Ok(BlockOutputs { Ok(BlockOutputs {
header: BlockHeaderInfo::from_header(&header), header: BlockHeaderInfo::from_header(&header),
@ -725,19 +726,22 @@ where
.and_then(move |wrapper: TxWrapper| { .and_then(move |wrapper: TxWrapper| {
util::from_hex(wrapper.tx_hex) util::from_hex(wrapper.tx_hex)
.map_err(|_| ErrorKind::RequestError("Bad request".to_owned()).into()) .map_err(|_| ErrorKind::RequestError("Bad request".to_owned()).into())
}).and_then(move |tx_bin| { })
.and_then(move |tx_bin| {
ser::deserialize(&mut &tx_bin[..]) ser::deserialize(&mut &tx_bin[..])
.map_err(|_| ErrorKind::RequestError("Bad request".to_owned()).into()) .map_err(|_| ErrorKind::RequestError("Bad request".to_owned()).into())
}).and_then(move |tx: Transaction| { })
.and_then(move |tx: Transaction| {
let source = pool::TxSource { let source = pool::TxSource {
debug_name: "push-api".to_string(), debug_name: "push-api".to_string(),
identifier: "?.?.?.?".to_string(), identifier: "?.?.?.?".to_string(),
}; };
info!( info!(
LOGGER, LOGGER,
"Pushing transaction with {} inputs and {} outputs to pool.", "Pushing transaction, inputs: {}, outputs: {}, kernels: {}, to pool.",
tx.inputs().len(), tx.inputs().len(),
tx.outputs().len() tx.outputs().len(),
tx.kernels().len(),
); );
// Push to tx pool. // Push to tx pool.

View file

@ -84,12 +84,20 @@ impl MessageHandler for Protocol {
} }
Type::Transaction => { Type::Transaction => {
debug!(
LOGGER,
"handle_payload: received tx: msg_len: {}", msg.header.msg_len
);
let tx: core::Transaction = msg.body()?; let tx: core::Transaction = msg.body()?;
adapter.transaction_received(tx, false); adapter.transaction_received(tx, false);
Ok(None) Ok(None)
} }
Type::StemTransaction => { Type::StemTransaction => {
debug!(
LOGGER,
"handle_payload: received stem tx: msg_len: {}", msg.header.msg_len
);
let tx: core::Transaction = msg.body()?; let tx: core::Transaction = msg.body()?;
adapter.transaction_received(tx, true); adapter.transaction_received(tx, true);
Ok(None) Ok(None)
@ -107,18 +115,19 @@ impl MessageHandler for Protocol {
} }
Type::Block => { Type::Block => {
debug!(
LOGGER,
"handle_payload: received block: msg_len: {}", msg.header.msg_len
);
let b: core::Block = msg.body()?; let b: core::Block = msg.body()?;
let bh = b.hash(); let bh = b.hash();
trace!(LOGGER, "handle_payload: Block {}", bh);
adapter.block_received(b, self.addr); adapter.block_received(b, self.addr);
Ok(None) Ok(None)
} }
Type::GetCompactBlock => { Type::GetCompactBlock => {
let h: Hash = msg.body()?; let h: Hash = msg.body()?;
debug!(LOGGER, "handle_payload: GetCompactBlock: {}", h);
if let Some(b) = adapter.get_block(h) { if let Some(b) = adapter.get_block(h) {
let cb = b.as_compact_block(); let cb = b.as_compact_block();
@ -147,9 +156,12 @@ impl MessageHandler for Protocol {
} }
Type::CompactBlock => { Type::CompactBlock => {
debug!(
LOGGER,
"handle_payload: received compact block: msg_len: {}", msg.header.msg_len
);
let b: core::CompactBlock = msg.body()?; let b: core::CompactBlock = msg.body()?;
let bh = b.hash(); let bh = b.hash();
debug!(LOGGER, "handle_payload: CompactBlock: {}", bh);
adapter.compact_block_received(b, self.addr); adapter.compact_block_received(b, self.addr);
Ok(None) Ok(None)
@ -161,10 +173,9 @@ impl MessageHandler for Protocol {
let headers = adapter.locate_headers(loc.hashes); let headers = adapter.locate_headers(loc.hashes);
// serialize and send all the headers over // serialize and send all the headers over
Ok(Some(msg.respond( Ok(Some(
Type::Headers, msg.respond(Type::Headers, Headers { headers: headers }),
Headers { headers: headers }, ))
)))
} }
// "header first" block propagation - if we have not yet seen this block // "header first" block propagation - if we have not yet seen this block
@ -268,7 +279,8 @@ impl MessageHandler for Protocol {
); );
let tmp_zip = File::open(tmp)?; let tmp_zip = File::open(tmp)?;
let res = self.adapter let res = self
.adapter
.txhashset_write(sm_arch.hash, tmp_zip, self.addr); .txhashset_write(sm_arch.hash, tmp_zip, self.addr);
debug!( debug!(

View file

@ -129,10 +129,13 @@ where
) -> Result<(), PoolError> { ) -> Result<(), PoolError> {
debug!( debug!(
LOGGER, LOGGER,
"pool [{}]: add_to_pool: {}, {:?}", "pool [{}]: add_to_pool: {}, {:?}, inputs: {}, outputs: {}, kernels: {}",
self.name, self.name,
entry.tx.hash(), entry.tx.hash(),
entry.src, entry.src,
entry.tx.inputs().len(),
entry.tx.outputs().len(),
entry.tx.kernels().len(),
); );
// Combine all the txs from the pool with any extra txs provided. // Combine all the txs from the pool with any extra txs provided.

View file

@ -97,14 +97,6 @@ where
tx: Transaction, tx: Transaction,
stem: bool, stem: bool,
) -> Result<(), PoolError> { ) -> Result<(), PoolError> {
debug!(
LOGGER,
"pool: add_to_pool: {:?}, kernels - {}, stem? {}",
tx.hash(),
tx.kernels().len(),
stem,
);
// Do we have the capacity to accept this transaction? // Do we have the capacity to accept this transaction?
self.is_acceptable(&tx)?; self.is_acceptable(&tx)?;

View file

@ -78,15 +78,17 @@ impl p2p::ChainAdapter for NetToChainAdapter {
identifier: "?.?.?.?".to_string(), identifier: "?.?.?.?".to_string(),
}; };
let h = tx.hash();
debug!( debug!(
LOGGER, LOGGER,
"Received tx {} from {:?}, going to process.", "Received tx {}, inputs: {}, outputs: {}, kernels: {}, going to process.",
tx.hash(), h,
source, tx.inputs().len(),
tx.outputs().len(),
tx.kernels().len(),
); );
let h = tx.hash();
let res = { let res = {
let mut tx_pool = self.tx_pool.write().unwrap(); let mut tx_pool = self.tx_pool.write().unwrap();
tx_pool.add_to_pool(source, tx, stem) tx_pool.add_to_pool(source, tx, stem)
@ -100,10 +102,13 @@ impl p2p::ChainAdapter for NetToChainAdapter {
fn block_received(&self, b: core::Block, addr: SocketAddr) -> bool { fn block_received(&self, b: core::Block, addr: SocketAddr) -> bool {
debug!( debug!(
LOGGER, LOGGER,
"Received block {} at {} from {}, going to process.", "Received block {} at {} from {}, inputs: {}, outputs: {}, kernels: {}, going to process.",
b.hash(), b.hash(),
b.header.height, b.header.height,
addr, addr,
b.inputs().len(),
b.outputs().len(),
b.kernels().len(),
); );
self.process_block(b, addr) self.process_block(b, addr)
} }
@ -112,10 +117,13 @@ impl p2p::ChainAdapter for NetToChainAdapter {
let bhash = cb.hash(); let bhash = cb.hash();
debug!( debug!(
LOGGER, LOGGER,
"Received compact_block {} at {} from {}, going to process.", "Received compact_block {} at {} from {}, outputs: {}, kernels: {}, kern_ids: {}, going to process.",
bhash, bhash,
cb.header.height, cb.header.height,
addr, addr,
cb.out_full.len(),
cb.kern_full.len(),
cb.kern_ids.len(),
); );
if cb.kern_ids.is_empty() { if cb.kern_ids.is_empty() {