Skip to content

Commit 294a8e1

Browse files
authored
Merge pull request Blockstream#41 from mempool/mononaut/block-tx-confs
Include tx confirmation status in bulk /block/txs response
2 parents 157dbf2 + de99ae3 commit 294a8e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/rest.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,15 +731,17 @@ fn handle_request(
731731
}
732732
(&Method::GET, Some(&INTERNAL_PREFIX), Some(&"block"), Some(hash), Some(&"txs"), None) => {
733733
let hash = BlockHash::from_hex(hash)?;
734+
let block_id = query.chain().blockid_by_hash(&hash);
734735
let txs = query
735736
.chain()
736737
.get_block_txs(&hash)
737738
.ok_or_else(|| HttpError::not_found("Block not found".to_string()))?
738739
.into_iter()
739-
.map(|tx| (tx, None))
740+
.map(|tx| (tx, block_id.clone()))
740741
.collect();
741742

742-
json_response(prepare_txs(txs, query, config), TTL_SHORT)
743+
let ttl = ttl_by_depth(block_id.map(|b| b.height), query);
744+
json_response(prepare_txs(txs, query, config), ttl)
743745
}
744746
(&Method::GET, Some(&"block"), Some(hash), Some(&"header"), None, None) => {
745747
let hash = BlockHash::from_hex(hash)?;

0 commit comments

Comments
 (0)