Ported acbe983 and 58d7dc7 from testnet1 branch
This commit is contained in:
+9
-8
@@ -33,8 +33,6 @@ use sumtree;
|
||||
use types::*;
|
||||
use util::LOGGER;
|
||||
|
||||
use core::global;
|
||||
|
||||
const MAX_ORPHANS: usize = 20;
|
||||
|
||||
/// Facade to the blockchain block processing pipeline and storage. Provides
|
||||
@@ -154,6 +152,15 @@ impl Chain {
|
||||
orphans.push_front((opts, b));
|
||||
orphans.truncate(MAX_ORPHANS);
|
||||
},
|
||||
Err(Error::Unfit(ref msg)) => {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Block {} at {} is unfit at this time: {}",
|
||||
b.hash(),
|
||||
b.header.height,
|
||||
msg
|
||||
);
|
||||
}
|
||||
Err(ref e) => {
|
||||
info!(
|
||||
LOGGER,
|
||||
@@ -184,12 +191,6 @@ impl Chain {
|
||||
}
|
||||
|
||||
fn ctx_from_head(&self, head: Tip, opts: Options) -> pipe::BlockContext {
|
||||
let opts = if global::is_production_mode() {
|
||||
opts
|
||||
} else {
|
||||
opts | EASY_POW
|
||||
};
|
||||
|
||||
pipe::BlockContext {
|
||||
opts: opts,
|
||||
store: self.store.clone(),
|
||||
|
||||
+1
-1
@@ -43,4 +43,4 @@ pub mod types;
|
||||
// Re-export the base interface
|
||||
|
||||
pub use chain::Chain;
|
||||
pub use types::{ChainAdapter, ChainStore, Error, Options, Tip, EASY_POW, NONE, SKIP_POW, SYNC};
|
||||
pub use types::{ChainAdapter, ChainStore, Error, Options, Tip, NONE, SKIP_POW, SYNC};
|
||||
|
||||
+2
-5
@@ -155,11 +155,8 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
||||
}
|
||||
|
||||
if !ctx.opts.intersects(SKIP_POW) {
|
||||
let cycle_size = if ctx.opts.intersects(EASY_POW) {
|
||||
global::sizeshift()
|
||||
} else {
|
||||
consensus::DEFAULT_SIZESHIFT
|
||||
};
|
||||
let cycle_size = global::sizeshift();
|
||||
|
||||
debug!(LOGGER, "Validating block with cuckoo size {}", cycle_size);
|
||||
if !(ctx.pow_verifier)(header, cycle_size as u32) {
|
||||
return Err(Error::InvalidPow);
|
||||
|
||||
@@ -32,8 +32,6 @@ bitflags! {
|
||||
const NONE = 0b00000001,
|
||||
/// Runs without checking the Proof of Work, mostly to make testing easier.
|
||||
const SKIP_POW = 0b00000010,
|
||||
/// Runs PoW verification with a lower cycle size.
|
||||
const EASY_POW = 0b00000100,
|
||||
/// Adds block while in syncing mode.
|
||||
const SYNC = 0b00001000,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user