@@ -6,7 +6,7 @@ use alloy_rpc_types_trace::geth::{
66} ;
77use async_trait:: async_trait;
88use cfx_rpc_eth_api:: DebugApiServer ;
9- use cfx_rpc_eth_types:: { BlockNumber , TransactionRequest } ;
9+ use cfx_rpc_eth_types:: { BlockId , TransactionRequest } ;
1010use cfx_rpc_utils:: error:: jsonrpsee_error_helpers:: invalid_params_msg;
1111use cfx_types:: { AddressSpaceUtil , Space , H256 , U256 } ;
1212use cfxcore:: {
@@ -36,19 +36,15 @@ impl DebugApi {
3636
3737 pub fn consensus_graph ( & self ) -> & ConsensusGraph { & self . consensus }
3838
39- pub fn get_block_epoch_num (
40- & self , block : BlockNumber ,
41- ) -> Result < u64 , String > {
39+ pub fn get_block_epoch_num ( & self , block : BlockId ) -> Result < u64 , String > {
4240 let num = match block {
43- BlockNumber :: Num ( block_number) => block_number,
44- BlockNumber :: Latest
45- | BlockNumber :: Safe
46- | BlockNumber :: Finalized => {
41+ BlockId :: Num ( block_number) => block_number,
42+ BlockId :: Latest | BlockId :: Safe | BlockId :: Finalized => {
4743 let epoch_num = block. try_into ( ) . expect ( "should success" ) ;
4844 self . consensus_graph ( )
4945 . get_height_from_epoch_number ( epoch_num) ?
5046 }
51- BlockNumber :: Hash {
47+ BlockId :: Hash {
5248 hash,
5349 require_canonical,
5450 } => self
@@ -64,8 +60,7 @@ impl DebugApi {
6460 }
6561
6662 pub fn trace_call (
67- & self , mut request : TransactionRequest ,
68- block_number : Option < BlockNumber > ,
63+ & self , mut request : TransactionRequest , block_number : Option < BlockId > ,
6964 opts : Option < GethDebugTracingCallOptions > ,
7065 ) -> Result < GethTrace , CoreError > {
7166 if request. from . is_none ( ) {
@@ -265,7 +260,7 @@ impl DebugApiServer for DebugApi {
265260 }
266261
267262 async fn debug_trace_block_by_number (
268- & self , block : BlockNumber , opts : Option < GethDebugTracingOptions > ,
263+ & self , block : BlockId , opts : Option < GethDebugTracingOptions > ,
269264 ) -> RpcResult < Vec < TraceResult > > {
270265 let num = self
271266 . get_block_epoch_num ( block)
@@ -275,7 +270,7 @@ impl DebugApiServer for DebugApi {
275270 }
276271
277272 async fn debug_trace_call (
278- & self , request : TransactionRequest , block_number : Option < BlockNumber > ,
273+ & self , request : TransactionRequest , block_number : Option < BlockId > ,
279274 opts : Option < GethDebugTracingCallOptions > ,
280275 ) -> RpcResult < GethTrace > {
281276 self . trace_call ( request, block_number, opts)
0 commit comments