add eth_blockNumber to rpc
This commit is contained in:
parent
b8c18ab765
commit
57ecba8fd2
|
@ -90,6 +90,11 @@ impl Client {
|
||||||
Ok(tip)
|
Ok(tip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_block_number(&self) -> Result<u64> {
|
||||||
|
let payload = self.consensus.get_execution_payload().await?;
|
||||||
|
Ok(payload.block_number)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn chain_id(&self) -> u64 {
|
pub fn chain_id(&self) -> u64 {
|
||||||
self.config.general.chain_id
|
self.config.general.chain_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ trait EthRpc {
|
||||||
async fn gas_price(&self) -> Result<String, Error>;
|
async fn gas_price(&self) -> Result<String, Error>;
|
||||||
#[method(name = "maxPriorityFeePerGas")]
|
#[method(name = "maxPriorityFeePerGas")]
|
||||||
async fn max_priority_fee_per_gas(&self) -> Result<String, Error>;
|
async fn max_priority_fee_per_gas(&self) -> Result<String, Error>;
|
||||||
|
#[method(name = "blockNumber")]
|
||||||
|
async fn block_number(&self) -> Result<String, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RpcInner {
|
struct RpcInner {
|
||||||
|
@ -144,6 +146,11 @@ impl EthRpcServer for RpcInner {
|
||||||
let tip = convert_err(self.client.get_priority_fee().await)?;
|
let tip = convert_err(self.client.get_priority_fee().await)?;
|
||||||
Ok(tip.encode_hex())
|
Ok(tip.encode_hex())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn block_number(&self) -> Result<String, Error> {
|
||||||
|
let num = convert_err(self.client.get_block_number().await)?;
|
||||||
|
Ok(u64_to_hex_string(num))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(rpc: RpcInner) -> Result<(HttpServerHandle, SocketAddr)> {
|
async fn start(rpc: RpcInner) -> Result<(HttpServerHandle, SocketAddr)> {
|
||||||
|
|
Loading…
Reference in New Issue