use reversed hashes in logging
This commit is contained in:
parent
6798fff50b
commit
cbd4227f35
|
@ -372,7 +372,7 @@ impl Storage {
|
||||||
/// all transaction meta is removed
|
/// all transaction meta is removed
|
||||||
/// DOES NOT update best block
|
/// DOES NOT update best block
|
||||||
fn decanonize_block(&self, context: &mut UpdateContext, hash: &H256) -> Result<(), Error> {
|
fn decanonize_block(&self, context: &mut UpdateContext, hash: &H256) -> Result<(), Error> {
|
||||||
trace!(target: "reorg", "Decanonizing block {}", hash);
|
trace!(target: "reorg", "Decanonizing block {}", hash.to_reversed_str());
|
||||||
|
|
||||||
// ensure that block is of the main chain
|
// ensure that block is of the main chain
|
||||||
try!(self.block_number(hash).ok_or(Error::not_main(hash)));
|
try!(self.block_number(hash).ok_or(Error::not_main(hash)));
|
||||||
|
|
|
@ -131,11 +131,11 @@ impl<T, U, V> LocalNode<T, U, V> where T: SynchronizationTaskExecutor + PeersCon
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_peer_transaction(&self, peer_index: usize, message: types::Tx) {
|
pub fn on_peer_transaction(&self, peer_index: usize, message: types::Tx) {
|
||||||
trace!(target: "sync", "Got `transaction` message from peer#{}. Transaction hash: {}", peer_index, message.transaction.hash());
|
trace!(target: "sync", "Got `transaction` message from peer#{}. Transaction hash: {}", peer_index, message.transaction.hash().to_reversed_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_peer_block(&self, peer_index: usize, message: types::Block) {
|
pub fn on_peer_block(&self, peer_index: usize, message: types::Block) {
|
||||||
trace!(target: "sync", "Got `block` message from peer#{}. Block hash: {}", peer_index, message.block.hash());
|
trace!(target: "sync", "Got `block` message from peer#{}. Block hash: {}", peer_index, message.block.hash().to_reversed_str());
|
||||||
|
|
||||||
// try to process new block
|
// try to process new block
|
||||||
self.client.lock().on_peer_block(peer_index, message.block);
|
self.client.lock().on_peer_block(peer_index, message.block);
|
||||||
|
|
|
@ -599,7 +599,13 @@ impl<T> SynchronizationClient<T> where T: TaskExecutor {
|
||||||
let new_blocks_hashes = hashes.split_off(new_block_index);
|
let new_blocks_hashes = hashes.split_off(new_block_index);
|
||||||
let new_blocks_headers = headers.split_off(new_block_index);
|
let new_blocks_headers = headers.split_off(new_block_index);
|
||||||
let new_blocks_hashes_len = new_blocks_hashes.len();
|
let new_blocks_hashes_len = new_blocks_hashes.len();
|
||||||
trace!(target: "sync", "Sch. {} headers from peer#{}. First {:?}, last: {:?}", new_blocks_hashes_len, peer_index, new_blocks_hashes[0], new_blocks_hashes[new_blocks_hashes_len - 1]);
|
trace!(
|
||||||
|
target: "sync", "Sch. {} headers from peer#{}. First {:?}, last: {:?}",
|
||||||
|
new_blocks_hashes_len,
|
||||||
|
peer_index,
|
||||||
|
new_blocks_hashes[0].to_reversed_str(),
|
||||||
|
new_blocks_hashes[new_blocks_hashes_len - 1].to_reversed_str()
|
||||||
|
);
|
||||||
chain.schedule_blocks_headers(new_blocks_hashes, new_blocks_headers);
|
chain.schedule_blocks_headers(new_blocks_hashes, new_blocks_headers);
|
||||||
// remember peer as useful
|
// remember peer as useful
|
||||||
self.peers.useful_peer(peer_index);
|
self.peers.useful_peer(peer_index);
|
||||||
|
@ -631,7 +637,12 @@ impl<T> SynchronizationClient<T> where T: TaskExecutor {
|
||||||
BlockState::Unknown => {
|
BlockState::Unknown => {
|
||||||
if self.state.is_synchronizing() {
|
if self.state.is_synchronizing() {
|
||||||
// when synchronizing, we tend to receive all blocks in-order
|
// when synchronizing, we tend to receive all blocks in-order
|
||||||
trace!(target: "sync", "Ignoring block {} from peer#{}, because its parent is unknown and we are synchronizing", block_hash, peer_index);
|
trace!(
|
||||||
|
target: "sync",
|
||||||
|
"Ignoring block {} from peer#{}, because its parent is unknown and we are synchronizing",
|
||||||
|
block_hash.to_reversed_str(),
|
||||||
|
peer_index
|
||||||
|
);
|
||||||
// remove block from current queue
|
// remove block from current queue
|
||||||
chain.forget(&block_hash);
|
chain.forget(&block_hash);
|
||||||
// remove orphaned blocks
|
// remove orphaned blocks
|
||||||
|
@ -826,7 +837,7 @@ impl<T> SynchronizationClient<T> where T: TaskExecutor {
|
||||||
chain.information());
|
chain.information());
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally - ask all known peers for their best blocks inventory, in case if some peer
|
// finally - ask all known peers for their best blocks inventory, in case if some peer
|
||||||
// has lead us to the fork
|
// has lead us to the fork
|
||||||
{
|
{
|
||||||
let mut executor = self.executor.lock();
|
let mut executor = self.executor.lock();
|
||||||
|
@ -1034,7 +1045,7 @@ pub mod tests {
|
||||||
|
|
||||||
let client = SynchronizationClient::new(config, &handle, executor.clone(), chain.clone());
|
let client = SynchronizationClient::new(config, &handle, executor.clone(), chain.clone());
|
||||||
(event_loop, handle, executor, chain, client)
|
(event_loop, handle, executor, chain, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn synchronization_saturated_on_start() {
|
fn synchronization_saturated_on_start() {
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl SynchronizationServer {
|
||||||
};
|
};
|
||||||
|
|
||||||
match server_task {
|
match server_task {
|
||||||
// `getdata` => `notfound` + `block` + ...
|
// `getdata` => `notfound` + `block` + ...
|
||||||
Some((peer_index, ServerTask::ServeGetData(inventory))) => {
|
Some((peer_index, ServerTask::ServeGetData(inventory))) => {
|
||||||
let mut unknown_items: Vec<InventoryVector> = Vec::new();
|
let mut unknown_items: Vec<InventoryVector> = Vec::new();
|
||||||
let mut new_tasks: Vec<ServerTask> = Vec::new();
|
let mut new_tasks: Vec<ServerTask> = Vec::new();
|
||||||
|
@ -279,7 +279,13 @@ impl Server for SynchronizationServer {
|
||||||
|
|
||||||
fn serve_getblocks(&self, peer_index: usize, message: types::GetBlocks) {
|
fn serve_getblocks(&self, peer_index: usize, message: types::GetBlocks) {
|
||||||
if let Some(best_common_block) = self.locate_known_block_hash(message.block_locator_hashes) {
|
if let Some(best_common_block) = self.locate_known_block_hash(message.block_locator_hashes) {
|
||||||
trace!(target: "sync", "Best common block with peer#{} is block#{}: {:?}", peer_index, best_common_block.number, best_common_block.hash);
|
trace!(
|
||||||
|
target: "sync",
|
||||||
|
"Best common block with peer#{} is block#{}: {:?}",
|
||||||
|
peer_index,
|
||||||
|
best_common_block.number,
|
||||||
|
best_common_block.hash.to_reversed_str(),
|
||||||
|
);
|
||||||
self.queue.lock().add_task(peer_index, ServerTask::ServeGetBlocks(best_common_block, message.hash_stop));
|
self.queue.lock().add_task(peer_index, ServerTask::ServeGetBlocks(best_common_block, message.hash_stop));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl Queue {
|
||||||
items.push_front(hash, ScheduleItem::Continued(item.block(), num));
|
items.push_front(hash, ScheduleItem::Continued(item.block(), num));
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
trace!(target: "verification", "Verification of block {} failed: {:?}", &hash, e);
|
trace!(target: "verification", "Verification of block {} failed: {:?}", hash.to_reversed_str(), e);
|
||||||
let mut invalid = self.invalid.write();
|
let mut invalid = self.invalid.write();
|
||||||
let mut processing = self.processing.write();
|
let mut processing = self.processing.write();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue