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,
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ fn mine_empty_chain() {
|
||||
).unwrap();
|
||||
|
||||
let bhash = b.hash();
|
||||
chain.process_block(b, chain::EASY_POW).unwrap();
|
||||
chain.process_block(b, chain::NONE).unwrap();
|
||||
|
||||
// checking our new head
|
||||
let head = chain.head().unwrap();
|
||||
|
||||
@@ -97,7 +97,7 @@ fn test_coinbase_maturity() {
|
||||
.contains(transaction::COINBASE_OUTPUT,)
|
||||
);
|
||||
|
||||
chain.process_block(block, chain::EASY_POW).unwrap();
|
||||
chain.process_block(block, chain::NONE).unwrap();
|
||||
|
||||
let prev = chain.head_header().unwrap();
|
||||
|
||||
@@ -126,7 +126,7 @@ fn test_coinbase_maturity() {
|
||||
global::sizeshift() as u32,
|
||||
).unwrap();
|
||||
|
||||
let result = chain.process_block(block, chain::EASY_POW);
|
||||
let result = chain.process_block(block, chain::NONE);
|
||||
match result {
|
||||
Err(Error::ImmatureCoinbase) => (),
|
||||
_ => panic!("expected ImmatureCoinbase error here"),
|
||||
@@ -154,7 +154,7 @@ fn test_coinbase_maturity() {
|
||||
global::sizeshift() as u32,
|
||||
).unwrap();
|
||||
|
||||
chain.process_block(block, chain::EASY_POW).unwrap();
|
||||
chain.process_block(block, chain::NONE).unwrap();
|
||||
}
|
||||
|
||||
let prev = chain.head_header().unwrap();
|
||||
@@ -175,7 +175,7 @@ fn test_coinbase_maturity() {
|
||||
global::sizeshift() as u32,
|
||||
).unwrap();
|
||||
|
||||
let result = chain.process_block(block, chain::EASY_POW);
|
||||
let result = chain.process_block(block, chain::NONE);
|
||||
match result {
|
||||
Ok(_) => (),
|
||||
Err(Error::ImmatureCoinbase) => panic!("we should not get an ImmatureCoinbase here"),
|
||||
|
||||
Reference in New Issue
Block a user