Background: This is added so we can reproduce the bug in D14361. It only occurs when Chronik is lagging behind the node, so to simulate this, we allow pausing and resuming Chronik indexing.
Note that this only pauses the indexing, querying the indexer still works fine (it might return old data though).
A commented-out reproduction of the bug mentioned in D14361 can be found in chronik_pause.py, this should be uncommented once the bug is fixed.
We enable pausing in Chronik by adding a pair of Pause and PauseNotify structs:
- Pause::block_if_paused allows blocking the thread if paused, until resumed by PauseNotify.
- PauseNotify blocks subsequent calls to Pause::block_if_paused, or resumes them.
Since we use the newer wait_for function of tokio, we update the tokio version to the most recent version.
Pause doesn't need to be behind any lock, so it won't result in a deadlock when e.g. trying to read from Chronik.
However, any call to SyncWithValidationInterfaceQueue while paused would block forever; this means we can't use the RPC methods like sendrawtransaction, submitblock, invalidateblock etc., we can however use the P2P network directly, e.g. with send_txs_and_test and send_blocks_and_test.