mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
fix our check_known check for blocks/headers (#2943)
This commit is contained in:
parent
7434eca5d0
commit
2348214719
2 changed files with 1 additions and 14 deletions
|
@ -386,7 +386,6 @@ impl Chain {
|
|||
verifier_cache: self.verifier_cache.clone(),
|
||||
txhashset,
|
||||
batch,
|
||||
orphans: self.orphans.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
//! Implementation of the chain block acceptance (or refusal) pipeline.
|
||||
|
||||
use crate::chain::OrphanBlockPool;
|
||||
use crate::core::consensus;
|
||||
use crate::core::core::hash::Hashed;
|
||||
use crate::core::core::verifier_cache::VerifierCache;
|
||||
|
@ -45,8 +44,6 @@ pub struct BlockContext<'a> {
|
|||
pub batch: store::Batch<'a>,
|
||||
/// The verifier cache (caching verifier for rangeproofs and kernel signatures)
|
||||
pub verifier_cache: Arc<RwLock<dyn VerifierCache>>,
|
||||
/// Recent orphan blocks to avoid double-processing
|
||||
pub orphans: Arc<OrphanBlockPool>,
|
||||
}
|
||||
|
||||
/// Process a block header as part of processing a full block.
|
||||
|
@ -77,7 +74,6 @@ fn process_header_for_block(
|
|||
// from cheapest to most expensive (delay hitting the db until last).
|
||||
fn check_known(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> {
|
||||
check_known_head(header, ctx)?;
|
||||
check_known_orphans(header, ctx)?;
|
||||
check_known_store(header, ctx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -261,6 +257,7 @@ pub fn process_block_header(header: &BlockHeader, ctx: &mut BlockContext<'_>) ->
|
|||
); // keep this
|
||||
|
||||
// Check if this header is already "known" from processing a previous block.
|
||||
// Note: We are looking for a full block based on this header, not just the header itself.
|
||||
check_known(header, ctx)?;
|
||||
|
||||
validate_header(header, ctx)?;
|
||||
|
@ -279,15 +276,6 @@ fn check_known_head(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Check if this block is in the set of known orphans.
|
||||
fn check_known_orphans(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> {
|
||||
if ctx.orphans.contains(&header.hash()) {
|
||||
Err(ErrorKind::Unfit("already known in orphans".to_string()).into())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this block is in the store already.
|
||||
fn check_known_store(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> {
|
||||
match ctx.batch.block_exists(&header.hash()) {
|
||||
|
|
Loading…
Reference in a new issue