Skip to content
Snippets Groups Projects
Commit 8bcfb16f authored by Arkadiy Paronyan's avatar Arkadiy Paronyan Committed by Gav Wood
Browse files

Fixed block import (#368)

* Fixed decoding from file

* Increased progress frequency
parent 4dfa17ab
No related merge requests found
......@@ -430,8 +430,8 @@ fn import_blocks<E>(matches: &clap::ArgMatches, exit: E) -> error::Result<()>
None => Box::new(stdin()),
};
info!("Importing blocks");
let count: u32 = Decode::decode(&mut file).ok_or("Error reading file")?;
info!("Importing {} blocks", count);
let mut block = 0;
for _ in 0 .. count {
if exit_recv.try_recv().is_ok() {
......@@ -448,7 +448,7 @@ fn import_blocks<E>(matches: &clap::ArgMatches, exit: E) -> error::Result<()>
}
}
block += 1;
if block % 10000 == 0 {
if block % 1000 == 0 {
info!("#{}", block);
}
}
......
......@@ -49,7 +49,10 @@ impl<'a> Input for &'a [u8] {
#[cfg(feature = "std")]
impl<R: ::std::io::Read> Input for R {
fn read(&mut self, into: &mut [u8]) -> usize {
(self as &mut ::std::io::Read).read(into).unwrap_or(0)
match (self as &mut ::std::io::Read).read_exact(into) {
Ok(()) => into.len(),
Err(_) => 0,
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment