Skip to content

Commit

Permalink
Comment MinerRpc's, use callback later
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Oct 13, 2023
1 parent 7c6875a commit b5ff255
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions rpc/src/module/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl MinerRpc for MinerRpcImpl {

let (verify_result_tx, verify_result_rx) =
ckb_channel::oneshot::channel::<std::result::Result<(), ckb_error::Error>>();
let verify_callback: fn(std::result::Result<(), ckb_error::Error>) =
let verify_callback =
move |verify_result: std::result::Result<(), ckb_error::Error>| match verify_result_tx
.send(verify_result)
{
Expand All @@ -286,22 +286,25 @@ impl MinerRpc for MinerRpcImpl {
self.chain
.process_block_with_callback(Arc::clone(&block), Box::new(verify_callback));

let is_new = verify_result_rx
.recv()
.map_err(|recv_err| {
RPCError::ckb_internal_error(format!(
"failed to receive verify result, error: {}",
recv_err
))
})?
.map_err(|verify_err| handle_submit_error(&work_id, &verify_err))?;
info!(
"end to submit block, work_id = {}, is_new = {}, block = #{}({})",
work_id,
is_new,
block.number(),
block.hash()
);
let is_new = true;
todo!("got a block is new or not via callback");

// let is_new = verify_result_rx
// .recv()
// .map_err(|recv_err| {
// RPCError::ckb_internal_error(format!(
// "failed to receive verify result, error: {}",
// recv_err
// ))
// })?
// .map_err(|verify_err| handle_submit_error(&work_id, &verify_err))?;
// info!(
// "end to submit block, work_id = {}, is_new = {}, block = #{}({})",
// work_id,
// is_new,
// block.number(),
// block.hash()
// );

// Announce only new block
if is_new {
Expand Down

0 comments on commit b5ff255

Please sign in to comment.