diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index cc67139e8e..202dbcca0f 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -129,7 +129,7 @@ impl, R: Routing> Rest { }; let router = { - let mut routes = axum::Router::new() + let routes = axum::Router::new() // All the endpoints before the call to `route_layer` are protected with JWT auth. .route(&format!("/{network}/node/address"), get(Self::get_node_address)) @@ -200,10 +200,8 @@ impl, R: Routing> Rest { // If the `history` feature is enabled, enable the additional endpoint. #[cfg(feature = "history")] - { - routes = - routes.route(&format!("/{network}/block/:blockHeight/history/:mapping"), get(Self::get_history)); - } + let routes = + routes.route(&format!("/{network}/block/:blockHeight/history/:mapping"), get(Self::get_history)); routes // Pass in `Rest` to make things convenient. diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 8cd65f1533..ef179ed8af 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -19,12 +19,10 @@ use snarkvm::{ prelude::{block::Transaction, Address, Identifier, LimitedWriter, Plaintext, ToBytes}, }; -use axum::response::IntoResponse; use indexmap::IndexMap; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use serde_json::json; -use snarkvm::prelude::{History, MappingName}; /// The `get_blocks` query object. #[derive(Deserialize, Serialize)] @@ -451,11 +449,13 @@ impl, R: Routing> Rest { #[cfg(feature = "history")] pub(crate) async fn get_history( State(rest): State, - Path((height, variant)): Path<(u32, MappingName)>, - ) -> Result { + Path((height, mapping)): Path<(u32, snarkvm::prelude::MappingName)>, + ) -> Result { // Retrieve the history for the given block height and variant. - let history = History::new(N::ID, rest.ledger.vm().finalize_store().storage_mode().clone()); - let result = history.load_entry(height, variant)?; + let history = snarkvm::prelude::History::new(N::ID, rest.ledger.vm().finalize_store().storage_mode().clone()); + let result = history + .load_mapping(height, mapping) + .map_err(|err| RestError(format!("Could not load mapping '{mapping}' from block '{height}'")))?; Ok((StatusCode::OK, [(CONTENT_TYPE, "application/json")], result)) }