This repository was archived by the owner on Nov 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
relay-chain-inprocess-interface/src
relay-chain-rpc-interface/src Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -242,9 +242,12 @@ impl RelayChainInterface for DummyRelayChainInterface {
242
242
async fn header ( & self , block_id : BlockId ) -> RelayChainResult < Option < PHeader > > {
243
243
let hash = match block_id {
244
244
BlockId :: Hash ( hash) => hash,
245
- BlockId :: Number ( num) => self . relay_client . hash ( num) ?. ok_or_else ( || {
246
- RelayChainError :: GenericError ( format ! ( "block with number {num} not found" ) )
247
- } ) ?,
245
+ BlockId :: Number ( num) =>
246
+ if let Some ( hash) = self . relay_client . hash ( num) ? {
247
+ hash
248
+ } else {
249
+ return Ok ( None )
250
+ } ,
248
251
} ;
249
252
let header = self . relay_client . header ( hash) ?;
250
253
Original file line number Diff line number Diff line change @@ -94,9 +94,12 @@ impl RelayChainInterface for RelayChainInProcessInterface {
94
94
async fn header ( & self , block_id : BlockId ) -> RelayChainResult < Option < PHeader > > {
95
95
let hash = match block_id {
96
96
BlockId :: Hash ( hash) => hash,
97
- BlockId :: Number ( num) => self . full_client . hash ( num) ?. ok_or_else ( || {
98
- RelayChainError :: GenericError ( format ! ( "block with number {num} not found" ) )
99
- } ) ?,
97
+ BlockId :: Number ( num) =>
98
+ if let Some ( hash) = self . full_client . hash ( num) ? {
99
+ hash
100
+ } else {
101
+ return Ok ( None )
102
+ } ,
100
103
} ;
101
104
let header = self . full_client . header ( hash) ?;
102
105
Original file line number Diff line number Diff line change @@ -82,9 +82,11 @@ impl RelayChainInterface for RelayChainRpcInterface {
82
82
let hash = match block_id {
83
83
BlockId :: Hash ( hash) => hash,
84
84
BlockId :: Number ( num) =>
85
- self . rpc_client . chain_get_block_hash ( Some ( num) ) . await ?. ok_or_else ( || {
86
- RelayChainError :: GenericError ( format ! ( "block with number {num} not found" ) )
87
- } ) ?,
85
+ if let Some ( hash) = self . rpc_client . chain_get_block_hash ( Some ( num) ) . await ? {
86
+ hash
87
+ } else {
88
+ return Ok ( None )
89
+ } ,
88
90
} ;
89
91
let header = self . rpc_client . chain_get_header ( Some ( hash) ) . await ?;
90
92
You can’t perform that action at this time.
0 commit comments