Skip to content

Commit

Permalink
get by blockheight not version
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmovses committed Jun 6, 2024
1 parent 25622d8 commit 54b1c17
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions protocol-units/maptos-rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,24 @@ impl MaptosRest {
pub fn create_routes(&self) -> impl EndpointExt {
Route::new()
.at("/health", get(health))
.at("/movement/v1/state-root-hash/:version/:ledger_info_version", get(state_root_hash))
.at("/movement/v1/state-root-hash/:blockheight/:", get(state_root_hash))
.data(self.context.clone())
.with(Tracing)
}
}

#[handler]
async fn state_root_hash(
Path(version): Path<u64>,
Path(ledger_info_version): Path<u64>,
Path(blockheight): Path<u64>,
context: Data<&Arc<Context>>,
) -> Result<Response, anyhow::Error> {
let txn_with_proof =
context.db.get_transaction_by_version(version, ledger_info_version, false)?;
let latest_ledger_info = context.db.get_latest_ledger_info()?;
let (_, end_version, _) = context.db.get_block_info_by_height(blockheight)?;
let txn_with_proof = context.db.get_transaction_by_version(
end_version,
latest_ledger_info.ledger_info().version(),
false,
)?;
let state_root_hash = txn_with_proof
.proof
.transaction_info
Expand Down

0 comments on commit 54b1c17

Please sign in to comment.