mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-18 11:37:40 +02:00
Merge #19550: rpc: Add getindexinfo RPC
124e1ee134doc: Add release notes for getindexinfo RPC (Fabian Jahr)c447b09458test: Add tests for getindexinfo RPC (Fabian Jahr)667bc7a7f7rpc: Add getindexinfo RPC (Fabian Jahr) Pull request description: As I was playing with indices a I was missing an RPC that gives information about the active indices in the node. I think this can be helpful for many users, especially since there are some new index candidates coming up (#14053, #18000) that can give a quick overview without the user having to parse the logs. Feature summary: - Adds new RPC `listindices` (placed in Util section) - That RPC only lists the actively running indices - For each index it gives the name, whether it is synced and up to which block height it is synced ACKs for top commit: laanwj: Re-ACK124e1ee134jonatack: Code review re-ACK124e1eeper `git range-diffa57af8947a5372 124e1ee` no change since my last re-ACK, rebase only Tree-SHA512: 3b7174c87951e6457fef099f530337803906baf32fb64261410b8def2c0917853d6a1bf3059cd590b1cc1523608f8916dafb327a431d27ecbf8d7454406b5b35
This commit is contained in:
@@ -61,6 +61,34 @@ class RpcMiscTest(BitcoinTestFramework):
|
||||
node.logging(include=['qt'])
|
||||
assert_equal(node.logging()['qt'], True)
|
||||
|
||||
self.log.info("test getindexinfo")
|
||||
# Without any indices running the RPC returns an empty object
|
||||
assert_equal(node.getindexinfo(), {})
|
||||
|
||||
# Restart the node with indices and wait for them to sync
|
||||
self.restart_node(0, ["-txindex", "-blockfilterindex"])
|
||||
self.wait_until(lambda: all(i["synced"] for i in node.getindexinfo().values()))
|
||||
|
||||
# Returns a list of all running indices by default
|
||||
assert_equal(
|
||||
node.getindexinfo(),
|
||||
{
|
||||
"txindex": {"synced": True, "best_block_height": 200},
|
||||
"basic block filter index": {"synced": True, "best_block_height": 200}
|
||||
}
|
||||
)
|
||||
|
||||
# Specifying an index by name returns only the status of that index
|
||||
assert_equal(
|
||||
node.getindexinfo("txindex"),
|
||||
{
|
||||
"txindex": {"synced": True, "best_block_height": 200},
|
||||
}
|
||||
)
|
||||
|
||||
# Specifying an unknown index name returns an empty result
|
||||
assert_equal(node.getindexinfo("foo"), {})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
RpcMiscTest().main()
|
||||
|
||||
Reference in New Issue
Block a user