Skip to content

Commit

Permalink
change the verifier name for sync and mining
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Oct 16, 2024
1 parent 8ad0ed6 commit 16b20f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::verifier::{BlockVerifier, DagVerifier, DagVerifierWithGhostData, FullVerifier};
use crate::verifier::{BlockVerifier, DagVerifierForMining, DagVerifierForSync, FullVerifier};
use anyhow::{bail, ensure, format_err, Ok, Result};
use sp_utils::stop_watch::{watch, CHAIN_WATCH_NAME};
use starcoin_accumulator::inmemory::InMemoryAccumulator;
Expand Down Expand Up @@ -1246,7 +1246,7 @@ impl ChainReader for BlockChain {
}

fn verify(&self, block: Block) -> Result<VerifiedBlock> {
DagVerifier::verify_block(self, block)
DagVerifierForMining::verify_block(self, block)
}

fn execute(&mut self, verified_block: VerifiedBlock) -> Result<ExecutedBlock> {
Expand Down Expand Up @@ -1725,14 +1725,14 @@ impl ChainWriter for BlockChain {
}

fn apply(&mut self, block: Block) -> Result<ExecutedBlock> {
self.apply_with_verifier::<DagVerifier>(block)
self.apply_with_verifier::<DagVerifierForMining>(block)
}

fn chain_state(&mut self) -> &ChainStateDB {
&self.statedb
}
fn apply_for_sync(&mut self, block: Block) -> Result<ExecutedBlock> {
self.apply_with_verifier::<DagVerifierWithGhostData>(block)
self.apply_with_verifier::<DagVerifierForSync>(block)
}
}

Expand Down
8 changes: 4 additions & 4 deletions chain/src/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ impl BasicDagVerifier {
}

// for mining
pub struct DagVerifier;
impl BlockVerifier for DagVerifier {
pub struct DagVerifierForMining;
impl BlockVerifier for DagVerifierForMining {
fn verify_header<R>(current_chain: &R, new_block_header: &BlockHeader) -> Result<()>
where
R: ChainReader,
Expand All @@ -451,8 +451,8 @@ impl BlockVerifier for DagVerifier {
}

// for sync
pub struct DagVerifierWithGhostData;
impl BlockVerifier for DagVerifierWithGhostData {
pub struct DagVerifierForSync;
impl BlockVerifier for DagVerifierForSync {
fn verify_header<R>(current_chain: &R, new_block_header: &BlockHeader) -> Result<()>
where
R: ChainReader,
Expand Down
5 changes: 3 additions & 2 deletions sync/src/block_connector/write_block_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ where
#[cfg(test)]
pub fn apply_failed(&mut self, block: Block) -> Result<()> {
use anyhow::bail;
use starcoin_chain::verifier::{DagVerifier, FullVerifier};
use starcoin_chain::verifier::{DagVerifierForMining, FullVerifier};

let verified_block = match self.main.check_chain_type()? {
ChainType::Single => {
Expand All @@ -257,7 +257,8 @@ where
}
ChainType::Dag => {
// apply but no connection
self.main.verify_with_verifier::<DagVerifier>(block)?
self.main
.verify_with_verifier::<DagVerifierForMining>(block)?
}
};
let _executed_block = self.main.execute(verified_block)?;
Expand Down
4 changes: 2 additions & 2 deletions sync/src/parallel/executor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use starcoin_chain::{verifier::DagVerifierWithGhostData, BlockChain, ChainReader};
use starcoin_chain::{verifier::DagVerifierForSync, BlockChain, ChainReader};
use starcoin_chain_api::ExecutedBlock;
use starcoin_config::TimeService;
use starcoin_crypto::HashValue;
Expand Down Expand Up @@ -168,7 +168,7 @@ impl DagBlockExecutor {
match chain
.as_mut()
.expect("it cannot be none!")
.apply_with_verifier::<DagVerifierWithGhostData>(block)
.apply_with_verifier::<DagVerifierForSync>(block)
{
Ok(executed_block) => {
info!(
Expand Down

0 comments on commit 16b20f8

Please sign in to comment.