Skip to content

Commit

Permalink
periodic debug during txhashset download
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Jun 20, 2019
1 parent 68dd906 commit 0052271
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions p2p/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::cmp;
use std::fs::{self, File, OpenOptions};
use std::io::{BufWriter, Seek, SeekFrom, Write};
use std::sync::Arc;
use std::time::Instant;
use tempfile::tempfile;

pub struct Protocol {
Expand Down Expand Up @@ -349,6 +350,7 @@ impl MessageHandler for Protocol {
let total_size = sm_arch.bytes as usize;
let mut downloaded_size: usize = 0;
let mut request_size = cmp::min(48_000, total_size);
let mut now = Instant::now();
while request_size > 0 {
let size = msg.copy_attachment(request_size, &mut tmp_zip)?;
downloaded_size += size;
Expand All @@ -358,6 +360,10 @@ impl MessageHandler for Protocol {
downloaded_size as u64,
total_size as u64,
);
if now.elapsed().as_secs() > 60 {
debug!("txhashset download: {}/{}", downloaded_size, total_size);
now = Instant::now();
}

// Increase received bytes quietly (without affecting the counters).
// Otherwise we risk banning a peer as "abusive".
Expand Down

0 comments on commit 0052271

Please sign in to comment.