Skip to content

Commit

Permalink
fix sync code
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Oct 13, 2023
1 parent f057caa commit 069de92
Show file tree
Hide file tree
Showing 164 changed files with 3,274 additions and 1,113 deletions.
65 changes: 44 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ api-limiter = { path = "commons/api-limiter" }
arc-swap = "1.5.1"
arrayref = "0.3"
ascii = "1.0.0"
async-std = "1.12"
async-std = { version = "1.12", features = ["attributes", "tokio1"] }
async-trait = "0.1.53"
asynchronous-codec = "0.5"
atomic-counter = "1.0.1"
Expand All @@ -257,6 +257,9 @@ bcs-ext = { path = "commons/bcs_ext" }
bech32 = "0.9"
bencher = "0.1.5"
bitflags = "1.3.2"
faster-hex = "0.6"
indexmap = "1.9.1"
bincode = { version = "1", default-features = false }
bs58 = "0.3.1"
byteorder = "1.3.4"
bytes = "1"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ChainBencher {
let block = ConsensusStrategy::Dummy
.create_block(block_template, self.net.time_service().as_ref())
.unwrap();
self.chain.write().apply(block).unwrap();
self.chain.write().apply(block, None, &mut None).unwrap();
}
}

Expand Down
18 changes: 13 additions & 5 deletions block-relayer/src/block_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ impl BlockRelayer {
&self,
network: NetworkServiceRef,
executed_block: Arc<ExecutedBlock>,
tips_header: Option<Vec<HashValue>>,
) {
if !self.is_nearly_synced() {
debug!("[block-relay] Ignore NewHeadBlock event because the node has not been synchronized yet.");
return;
}
let compact_block = executed_block.block().clone().into();
let compact_block_msg =
CompactBlockMessage::new(compact_block, executed_block.block_info.clone());
let compact_block_msg = CompactBlockMessage::new(
compact_block,
executed_block.block_info.clone(),
tips_header,
);
network.broadcast(NotificationMessage::CompactBlock(Box::new(
compact_block_msg,
)));
Expand Down Expand Up @@ -240,7 +244,11 @@ impl BlockRelayer {
)
.await?;

block_connector_service.notify(PeerNewBlock::new(peer_id, block))?;
block_connector_service.notify(PeerNewBlock::new(
peer_id,
block,
compact_block_msg.message.tips_header,
))?;
}
Ok(())
};
Expand Down Expand Up @@ -288,7 +296,7 @@ impl EventHandler<Self, NewHeadBlock> for BlockRelayer {
return;
}
};
self.broadcast_compact_block(network, event.0);
self.broadcast_compact_block(network, event.0, event.1);
}
}

Expand All @@ -305,7 +313,7 @@ impl EventHandler<Self, NewBranch> for BlockRelayer {
return;
}
};
self.broadcast_compact_block(network, event.0);
self.broadcast_compact_block(network, event.0, event.1);
}
}

Expand Down
2 changes: 2 additions & 0 deletions chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ starcoin-types = { package = "starcoin-types", workspace = true }
starcoin-vm-types = { workspace = true }
starcoin-storage = { workspace = true }
thiserror = { workspace = true }
starcoin-network-rpc-api = { workspace = true }

[dev-dependencies]
proptest = { workspace = true }
Expand All @@ -39,6 +40,7 @@ stdlib = { workspace = true }
stest = { workspace = true }
test-helper = { workspace = true }
tokio = { features = ["full"], workspace = true }
starcoin-network-rpc-api = { workspace = true }

[features]
default = []
Expand Down
1 change: 1 addition & 0 deletions chain/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ starcoin-time-service = { workspace = true }
starcoin-types = { workspace = true }
starcoin-vm-types = { workspace = true }
thiserror = { workspace = true }
starcoin-network-rpc-api = { workspace = true }


[dev-dependencies]
Expand Down
Loading

0 comments on commit 069de92

Please sign in to comment.