Changeset View
Changeset View
Standalone View
Standalone View
chronik/chronik-http/src/server.rs
| Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | |||||
| ) -> Result<Protobuf<proto::Block>, ReportError> { | ) -> Result<Protobuf<proto::Block>, ReportError> { | ||||
| let indexer = indexer.read().await; | let indexer = indexer.read().await; | ||||
| let blocks = indexer.blocks(&node); | let blocks = indexer.blocks(&node); | ||||
| Ok(Protobuf(blocks.by_hash_or_height(hash_or_height)?)) | Ok(Protobuf(blocks.by_hash_or_height(hash_or_height)?)) | ||||
| } | } | ||||
| async fn handle_block_header( | async fn handle_block_header( | ||||
| Path(hash_or_height): Path<String>, | Path(hash_or_height): Path<String>, | ||||
| Query(query_params): Query<HashMap<String, String>>, | |||||
| Extension(indexer): Extension<ChronikIndexerRef>, | Extension(indexer): Extension<ChronikIndexerRef>, | ||||
| Extension(node): Extension<NodeRef>, | Extension(node): Extension<NodeRef>, | ||||
| ) -> Result<Protobuf<proto::BlockHeader>, ReportError> { | ) -> Result<Protobuf<proto::BlockHeader>, ReportError> { | ||||
| let indexer = indexer.read().await; | let indexer = indexer.read().await; | ||||
| let blocks = indexer.blocks(&node); | Ok(Protobuf( | ||||
| Ok(Protobuf(blocks.header(hash_or_height)?)) | handlers::handle_block_header( | ||||
| hash_or_height, | |||||
| &query_params, | |||||
| &indexer, | |||||
| &node, | |||||
| ) | |||||
| .await?, | |||||
| )) | |||||
| } | } | ||||
| async fn handle_block_headers( | async fn handle_block_headers( | ||||
| Path((start_height, end_height)): Path<(i32, i32)>, | Path((start_height, end_height)): Path<(i32, i32)>, | ||||
| Query(query_params): Query<HashMap<String, String>>, | |||||
| Extension(indexer): Extension<ChronikIndexerRef>, | Extension(indexer): Extension<ChronikIndexerRef>, | ||||
| Extension(node): Extension<NodeRef>, | Extension(node): Extension<NodeRef>, | ||||
| ) -> Result<Protobuf<proto::BlockHeaders>, ReportError> { | ) -> Result<Protobuf<proto::BlockHeaders>, ReportError> { | ||||
| let indexer = indexer.read().await; | let indexer = indexer.read().await; | ||||
| let blocks = indexer.blocks(&node); | Ok(Protobuf( | ||||
| Ok(Protobuf(blocks.headers_by_range(start_height, end_height)?)) | handlers::handle_block_headers( | ||||
| start_height, | |||||
| end_height, | |||||
| &query_params, | |||||
| &indexer, | |||||
| &node, | |||||
| ) | |||||
| .await?, | |||||
| )) | |||||
| } | } | ||||
| async fn handle_block_txs( | async fn handle_block_txs( | ||||
| Path(hash_or_height): Path<String>, | Path(hash_or_height): Path<String>, | ||||
| Query(query_params): Query<HashMap<String, String>>, | Query(query_params): Query<HashMap<String, String>>, | ||||
| Extension(indexer): Extension<ChronikIndexerRef>, | Extension(indexer): Extension<ChronikIndexerRef>, | ||||
| Extension(node): Extension<NodeRef>, | Extension(node): Extension<NodeRef>, | ||||
| ) -> Result<Protobuf<proto::TxHistoryPage>, ReportError> { | ) -> Result<Protobuf<proto::TxHistoryPage>, ReportError> { | ||||
| ▲ Show 20 Lines • Show All 385 Lines • Show Last 20 Lines | |||||