Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/serve/grpc/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,16 @@ fn apply_predicate(predicate: &u5c::watch::TxPredicate, tx: &u5c::cardano::Tx) -
}

fn block_to_txs<C: LedgerContext>(
block: &RawBlock,
raw_block: &RawBlock,
mapper: &interop::Mapper<C>,
request: &u5c::watch::WatchTxRequest,
) -> Vec<u5c::watch::AnyChainTx> {
let block = MultiEraBlock::decode(block).unwrap();
let include_block = request.field_mask.as_ref().map_or(false, |mask| {
mask.paths.iter().any(|p| p.contains("block"))
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

let body: &BlockBody = &raw_block;
let block = MultiEraBlock::decode(raw_block).unwrap();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
let txs = block.txs();

txs.iter()
Expand All @@ -164,8 +169,16 @@ fn block_to_txs<C: LedgerContext>(
})
.map(|x| u5c::watch::AnyChainTx {
chain: Some(u5c::watch::any_chain_tx::Chain::Cardano(x)),
// TODO(p): should it be none?
block: None,
block: if include_block {
Some(u5c::watch::AnyChainBlock {
native_bytes: body.to_vec().into(),
chain: Some(u5c::watch::any_chain_block::Chain::Cardano(
mapper.map_block_cbor(body),
)),
})
} else {
None
},
})
.collect()
}
Expand Down