small fixes for importing unordered blocks
This commit is contained in:
parent
4713c1797c
commit
a969a04127
|
@ -579,7 +579,7 @@ impl BlockStapler for Storage {
|
|||
// write accumulated transactions meta
|
||||
try!(context.apply(&self.database));
|
||||
|
||||
trace!(target: "db", "Best block now ({}, {})", &new_best_hash, &new_best_number);
|
||||
trace!(target: "db", "Best block now ({}, {})", &new_best_hash.to_reversed_str(), &new_best_number);
|
||||
// updating locked best block
|
||||
*best_block = Some(BestBlock { hash: new_best_hash, number: new_best_number });
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::{io, fs, path};
|
||||
use std::collections::BTreeSet;
|
||||
use ser::{ReadIterator, deserialize_iterator, Error as ReaderError};
|
||||
use block::Block;
|
||||
use fs::read_blk_dir;
|
||||
|
@ -25,9 +26,11 @@ impl Iterator for BlkFile {
|
|||
}
|
||||
|
||||
pub fn open_blk_dir<P>(path: P) -> Result<BlkDir, io::Error> where P: AsRef<path::Path> {
|
||||
let iter = try!(read_blk_dir(path))
|
||||
let files = read_blk_dir(path)?.collect::<Result<BTreeSet<_>, _>>()?;
|
||||
|
||||
let iter = files.into_iter()
|
||||
// flatten results...
|
||||
.flat_map(|entry| entry.and_then(|file| open_blk_file(file.path)))
|
||||
.flat_map(|file| open_blk_file(file.path))
|
||||
// flat iterators over each block in each file
|
||||
.flat_map(|file| file);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{io, fs, path};
|
||||
use std::{io, fs, path, cmp};
|
||||
|
||||
/// Creates an iterator over all blk .dat files
|
||||
pub fn read_blk_dir<P>(path: P) -> Result<ReadBlkDir, io::Error> where P: AsRef<path::Path> {
|
||||
|
@ -13,10 +13,23 @@ pub struct ReadBlkDir {
|
|||
read_dir: fs::ReadDir,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct BlkEntry {
|
||||
pub path: path::PathBuf,
|
||||
}
|
||||
|
||||
impl cmp::PartialOrd for BlkEntry {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
||||
cmp::PartialOrd::partial_cmp(&self.path, &other.path)
|
||||
}
|
||||
}
|
||||
|
||||
impl cmp::Ord for BlkEntry {
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
cmp::Ord::cmp(&self.path, &other.path)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_blk_file_name(file_name: &str) -> bool {
|
||||
if file_name.len() != 12 || !file_name.starts_with("blk") || !file_name.ends_with(".dat") {
|
||||
return false;
|
||||
|
|
|
@ -31,8 +31,8 @@ impl ConsensusParams {
|
|||
}
|
||||
|
||||
pub fn is_bip30_exception(&self, hash: &H256, height: u32) -> bool {
|
||||
(height == 91842 && hash == &H256::from_reversed_str("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
|
||||
(height == 91880 && hash == &H256::from_reversed_str("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"))
|
||||
(height == 91842 && hash == &H256::from_reversed_str("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
|
||||
(height == 91880 && hash == &H256::from_reversed_str("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use synchronization_verifier::{Verifier, SyncVerifier, VerificationSink};
|
|||
use primitives::hash::H256;
|
||||
use super::Error;
|
||||
|
||||
pub const MAX_ORPHANED_BLOCKS: usize = 64;
|
||||
pub const MAX_ORPHANED_BLOCKS: usize = 1024;
|
||||
|
||||
pub struct BlocksWriter {
|
||||
storage: db::SharedStore,
|
||||
|
|
Loading…
Reference in New Issue