Page MenuHomePhabricator

[Chronik] Index txs; add `/tx/:txid` HTTP endpoint
ClosedPublic

Authored by tobias_ruck on Mar 25 2023, 21:50.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC9514a0915212: [Chronik] Index txs; add `/tx/:txid` HTTP endpoint
Summary

We add transactions to the DB as new blocks are coming in using TxWriter. Until we index the mempool, we set the time_first_seen to 0.

/tx/:txid returns txs by txid from the DB using the QueryTxs struct; not from the mempool yet though, which will be in a future diff.

We also add a few new protobuf messages: Tx, OutPoint, TxInput, TxOutput, BlockMetadata and Network.

Test Plan

ninja check-crates && ninja && ./test/functional/test_runner.py chronik_tx

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Factor out connect_block and disconnect_block, include block hash and num txs in log

Fabien requested changes to this revision.Mar 27 2023, 14:35
Fabien added inline comments.
chronik/chronik-indexer/src/query/txs.rs
50–55 ↗(On Diff #38912)

Nit: no need to instanciate a block reader if the tx is not found

chronik/chronik-proto/proto/chronik.proto
48 ↗(On Diff #38912)

What's the use for that one ? Is there any chronik instance that can index several chains ?

test/functional/chronik_tx.py
28 ↗(On Diff #38912)
171 ↗(On Diff #38912)

dito

This revision now requires changes to proceed.Mar 27 2023, 14:35

Remove 'network' field from proto; small nits

This revision is now accepted and ready to land.Mar 27 2023, 16:17