Skip to content

Commit

Permalink
breadcast_compact_block only when FirstSeenAndVerified
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Nov 22, 2023
1 parent f271d4b commit f74f43c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions rpc/src/module/miner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::error::RPCError;
use ckb_chain::ChainController;
use ckb_chain::{ChainController, VerifiedBlockStatus, VerifyResult};
use ckb_jsonrpc_types::{Block, BlockTemplate, Uint64, Version};
use ckb_logger::{debug, error, warn};
use ckb_network::{NetworkController, PeerIndex, SupportProtocols, TargetSession};
Expand Down Expand Up @@ -271,10 +271,10 @@ impl MinerRpc for MinerRpcImpl {
.verify(&header)
.map_err(|err| handle_submit_error(&work_id, &err))?;

let verify_result = self.chain.blocking_process_block(Arc::clone(&block));
let verify_result: VerifyResult = self.chain.blocking_process_block(Arc::clone(&block));

// TODO: need to consider every enum item of verify_result
let is_new = verify_result.is_ok();
// TODO: review this logic
let is_new = matches!(verify_result, Ok(VerifiedBlockStatus::FirstSeenAndVerified));

// Announce only new block
if is_new {
Expand Down
3 changes: 1 addition & 2 deletions sync/src/relayer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ impl Relayer {
let peer = peer.clone();
move |result: VerifyResult| match result {
Ok(verified_block_status) => match verified_block_status {
VerifiedBlockStatus::FirstSeenAndVerified
| VerifiedBlockStatus::FirstSeenButNotVerified => {
VerifiedBlockStatus::FirstSeenAndVerified => {
match broadcast_compact_block_tx.send((block, peer)) {
Err(_) => {
error!(
Expand Down

0 comments on commit f74f43c

Please sign in to comment.