Skip to content

Commit

Permalink
Implement mempool endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lrubasze committed Nov 11, 2024
1 parent 4b4086c commit 338e6ce
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core-rust/mesh-api-server/src/mesh_api/handlers/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ pub(crate) async fn handle_mempool(
) -> Result<Json<models::MempoolResponse>, ResponseError> {
assert_matching_network(&request.network_identifier, &state.network)?;

// let database = state.state_manager.database.snapshot();
// let mapping_context = MappingContext::new(&state.network);
let mapping_context = MappingContext::new(&state.network);
let mempool = state.state_manager.mempool.read();

Ok(Json(models::MempoolResponse::new(vec![])))
Ok(Json(models::MempoolResponse::new(
mempool
.all_hashes_iter()
.map(|(intent_hash, _)| {
Ok(models::TransactionIdentifier {
hash: to_api_transaction_hash_bech32m(&mapping_context, intent_hash)?,
})
})
.collect::<Result<Vec<_>, MappingError>>()?,
)))
}

0 comments on commit 338e6ce

Please sign in to comment.