Skip to content

Commit

Permalink
add some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Sep 2, 2024
1 parent 2e4e560 commit 95215f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
10 changes: 5 additions & 5 deletions sync/src/parallel/executor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use starcoin_chain::{verifier::DagVerifier, BlockChain, ChainReader};
use starcoin_chain_api::ExecutedBlock;
use starcoin_config::TimeService;
use starcoin_crypto::HashValue;
use starcoin_dag::blockdag::BlockDAG;
Expand All @@ -16,7 +17,7 @@ use tokio::{
pub enum ExecuteState {
Ready(HashValue),
Executing(HashValue),
Executed(BlockHeader),
Executed(ExecutedBlock),
Error(BlockHeader),
Closed,
}
Expand Down Expand Up @@ -129,15 +130,14 @@ impl DagBlockExecutor {
info!("sync parallel worker {:p} will execute block: {:?}", &self, block.header().id());
match chain.as_mut().expect("it cannot be none!").apply_with_verifier::<DagVerifier>(block) {
Ok(executed_block) => {
let header = executed_block.header();
info!(
"succeed to execute block: number: {:?}, id: {:?}",
header.number(),
header.id()
executed_block.header().number(),
executed_block.header().id()
);
match self
.sender
.send(ExecuteState::Executed(header.clone()))
.send(ExecuteState::Executed(executed_block))
.await
{
Ok(_) => (),
Expand Down
14 changes: 3 additions & 11 deletions sync/src/parallel/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ impl DagBlockSender {
async fn dispatch_to_worker(&mut self, block: &Block) -> anyhow::Result<bool> {
for executor in &mut self.executors {
match &executor.state {
// ExecuteState::Executed(executing_header_block) => {
// if executing_header_block.id() == block.header().parent_hash() {
// executor.state = ExecuteState::Executing(block.id());
// executor.sender_to_executor.send(block.clone()).await?;
// return anyhow::Ok(true);
// }
// }
ExecuteState::Executing(header_id) => {
if *header_id == block.header().parent_hash() || block.header.parents_hash().contains(header_id) {
executor.state = ExecuteState::Executing(block.id());
Expand Down Expand Up @@ -129,8 +122,6 @@ impl DagBlockSender {
self.flush_executor_state().await?;
}

self.sync_dag_store.delete_all_dag_sync_block()?;

self.wait_for_finish().await?;

Ok(())
Expand All @@ -141,8 +132,9 @@ impl DagBlockSender {
match worker.receiver_from_executor.try_recv() {
Ok(state) => {
match state {
ExecuteState::Executed(header_id) => {
worker.state = ExecuteState::Executed(header_id);
ExecuteState::Executed(executed_block) => {
self.sync_dag_store.delete_dag_sync_block(executed_block.block().header().number(), executed_block.header().id())?;
worker.state = ExecuteState::Executed(executed_block);
}
_ => ()
}
Expand Down

0 comments on commit 95215f1

Please sign in to comment.