handle null case
This commit is contained in:
parent
33f7256236
commit
a54a061bd2
@ -149,16 +149,16 @@ impl Web3Connections {
|
|||||||
let get_block_params = (*hash, false);
|
let get_block_params = (*hash, false);
|
||||||
// TODO: if error, retry?
|
// TODO: if error, retry?
|
||||||
let block: ArcBlock = match rpc {
|
let block: ArcBlock = match rpc {
|
||||||
Some(rpc) => {
|
Some(rpc) => rpc
|
||||||
rpc.wait_for_request_handle(authorization, Duration::from_secs(30), false)
|
.wait_for_request_handle(authorization, Duration::from_secs(30), false)
|
||||||
.await?
|
.await?
|
||||||
.request(
|
.request::<_, Option<_>>(
|
||||||
"eth_getBlockByHash",
|
"eth_getBlockByHash",
|
||||||
&json!(get_block_params),
|
&json!(get_block_params),
|
||||||
Level::Error.into(),
|
Level::Error.into(),
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
.context("no block!")?,
|
||||||
None => {
|
None => {
|
||||||
// TODO: helper for method+params => JsonRpcRequest
|
// TODO: helper for method+params => JsonRpcRequest
|
||||||
// TODO: does this id matter?
|
// TODO: does this id matter?
|
||||||
@ -172,7 +172,9 @@ impl Web3Connections {
|
|||||||
|
|
||||||
let block = response.result.context("failed fetching block")?;
|
let block = response.result.context("failed fetching block")?;
|
||||||
|
|
||||||
serde_json::from_str(block.get())?
|
let block: Option<ArcBlock> = serde_json::from_str(block.get())?;
|
||||||
|
|
||||||
|
block.context("no block!")?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -193,13 +193,14 @@ impl Web3Connection {
|
|||||||
let head_block: ArcBlock = self
|
let head_block: ArcBlock = self
|
||||||
.wait_for_request_handle(authorization, Duration::from_secs(30), true)
|
.wait_for_request_handle(authorization, Duration::from_secs(30), true)
|
||||||
.await?
|
.await?
|
||||||
.request(
|
.request::<_, Option<_>>(
|
||||||
"eth_getBlockByNumber",
|
"eth_getBlockByNumber",
|
||||||
&json!(("latest", false)),
|
&json!(("latest", false)),
|
||||||
// error here are expected, so keep the level low
|
// error here are expected, so keep the level low
|
||||||
Level::Debug.into(),
|
Level::Debug.into(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?
|
||||||
|
.context("no block!")?;
|
||||||
|
|
||||||
if SavedBlock::from(head_block).syncing() {
|
if SavedBlock::from(head_block).syncing() {
|
||||||
// if the node is syncing, we can't check its block data limit
|
// if the node is syncing, we can't check its block data limit
|
||||||
|
Loading…
Reference in New Issue
Block a user