fix off by one error
This commit is contained in:
parent
4683eadc89
commit
ce1b0da1e3
@ -4,7 +4,7 @@ use ethers::{
|
|||||||
prelude::{BlockNumber, U64},
|
prelude::{BlockNumber, U64},
|
||||||
types::H256,
|
types::H256,
|
||||||
};
|
};
|
||||||
use log::{trace, warn};
|
use log::{debug, trace, warn};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -56,14 +56,16 @@ pub async fn clean_block_number(
|
|||||||
}
|
}
|
||||||
Some(params) => match params.get_mut(block_param_id) {
|
Some(params) => match params.get_mut(block_param_id) {
|
||||||
None => {
|
None => {
|
||||||
if params.len() != block_param_id - 1 {
|
if params.len() == block_param_id {
|
||||||
// TODO: this needs the correct error code in the response
|
// add the latest block number to the end of the params
|
||||||
return Err(anyhow::anyhow!("unexpected params length"));
|
params.push(serde_json::to_value(latest_block)?);
|
||||||
|
} else {
|
||||||
|
// don't modify the request. only cache with current block
|
||||||
|
// TODO: more useful log that include the
|
||||||
|
warn!("unexpected params length");
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the latest block number to the end of the params
|
// don't modify params, just cache with the current block
|
||||||
params.push(serde_json::to_value(latest_block)?);
|
|
||||||
|
|
||||||
Ok(latest_block)
|
Ok(latest_block)
|
||||||
}
|
}
|
||||||
Some(x) => {
|
Some(x) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user