Subscribe to get the new header when a block is connected.
Details
Details
- Reviewers
- None
- Group Reviewers
Restricted Project
TODO: needs integration tests
In terminal 1:
./src/bitcoind -regtest -debug=chronik -chronik -chronikscripthashindex -chronikelectrumbind="127.0.0.1:50001"
In terminal 2 (can be done in several terminals):
echo '{"jsonrpc": "2.0", "method": "blockchain.headers.subscribe", "params": [], "id": "test"}' | nc 127.0.0.1 50001 | jq
in terminal 3:
./src/bitcoin-cli -regtest create regtest ./src/bitcoin-cli -regtest -generate 1
Diff Detail
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- chronik_electrum_headers_subscribe
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Event Timeline
chronik/chronik-indexer/src/subs.rs | ||
---|---|---|
65 | is reusing subs_block not an option? |
chronik/chronik-indexer/src/subs.rs | ||
---|---|---|
65 | Could be, but I'm only interested in the connection event so having a different broadcast channel makes the code a bit simpler |
chronik/chronik-indexer/src/subs.rs | ||
---|---|---|
65 | Well you add a lot of complexity in subs.rs (which is kind of a common shared module) in order to remove a if msg.msg_type != BlockMsgType::Connected { continue; } in your code, which seem suboptimal |
Comment Actions
Reuse block subscription. This requires to add a filter on the event but overall simplifies the code.