MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / query_height

Method query_height

fendermint/eth/api/src/state.rs:257–274  ·  view source on GitHub ↗

Return the height of a block which we should send with a query, or None if it's the latest, to let the node figure it out. Adjusts the height of the query to +1 so the effects of the block is visible. The node stores the results at height+1 to be consistent with how CometBFT works, ie. the way it publishes the state hash in the *next* block. The assumption here is that the client got the height

(&self, block_id: et::BlockId)

Source from the content-addressed store, hash-verified

255 ///
256 /// In both cases we know that there should be state stored at height + 1.
257 pub async fn query_height(&self, block_id: et::BlockId) -> JsonRpcResult<FvmQueryHeight> {
258 match block_id {
259 et::BlockId::Number(bn) => match bn {
260 // The client might be asking by height of a block, expecting to see the results.
261 et::BlockNumber::Number(height) => Ok(FvmQueryHeight::from(height.as_u64() + 1)),
262 et::BlockNumber::Finalized | et::BlockNumber::Latest | et::BlockNumber::Safe => {
263 Ok(FvmQueryHeight::Committed)
264 }
265 et::BlockNumber::Pending => Ok(FvmQueryHeight::Pending),
266 et::BlockNumber::Earliest => Ok(FvmQueryHeight::Height(1)),
267 },
268 et::BlockId::Hash(h) => {
269 // The effects of this block are saved at the next height.
270 let header = self.header_by_hash(h).await?;
271 Ok(FvmQueryHeight::Height(header.height.value() + 1))
272 }
273 }
274 }
275
276 /// Get a Tendermint block by hash, if it exists.
277 pub async fn block_by_hash_opt(

Callers 6

get_balanceFunction · 0.80
get_transaction_countFunction · 0.80
callFunction · 0.80
estimate_gasFunction · 0.80
get_storage_atFunction · 0.80
get_codeFunction · 0.80

Calls 1

header_by_hashMethod · 0.80

Tested by

no test coverage detected