commands: add a 'rescan_progress' field to 'getinfo'

We make sure to return a value as long as it was not wiped from
database, that's useful in functional tests.
This commit is contained in:
Antoine Poinsot 2022-11-09 18:21:39 +01:00
parent 7866ff46cf
commit 073cdd0a89
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 14 additions and 7 deletions

View File

@ -43,13 +43,14 @@ This command does not take any parameter for now.
#### Response
| Field | Type | Description |
| -------------------- | ------- | -------------------------------------------------------------------------------------------- |
| `version` | string | Version following the [SimVer](http://www.simver.org/) format |
| `network` | string | Answer can be `mainnet`, `testnet`, `regtest` |
| `blockheight` | integer | The block height we are synced at. |
| `sync` | float | The synchronization progress as percentage (`0 < sync < 1`) |
| `descriptors` | object | Object with the name of the descriptor as key and the descriptor string as value |
| Field | Type | Description |
| -------------------- | ------- | -------------------------------------------------------------------------------------------------- |
| `version` | string | Version following the [SimVer](http://www.simver.org/) format |
| `network` | string | Answer can be `mainnet`, `testnet`, `regtest` |
| `blockheight` | integer | The block height we are synced at. |
| `sync` | float | The synchronization progress as percentage (`0 < sync < 1`) |
| `descriptors` | object | Object with the name of the descriptor as key and the descriptor string as value |
| `rescan_progress` | float or null | Progress of an ongoing rescan as a percentage (between 0 and 1) if there is any |
### `getnewaddress`

View File

@ -196,6 +196,9 @@ impl DaemonControl {
let mut db_conn = self.db.connection();
let blockheight = db_conn.chain_tip().map(|tip| tip.height).unwrap_or(0);
let rescan_progress = db_conn
.rescan_timestamp()
.map(|_| self.bitcoin.rescan_progress().unwrap_or(1.0));
GetInfoResult {
version: VERSION.to_string(),
network: self.config.bitcoin_config.network,
@ -204,6 +207,7 @@ impl DaemonControl {
descriptors: GetInfoDescriptors {
main: self.config.main_descriptor.clone(),
},
rescan_progress,
}
}
@ -535,6 +539,8 @@ pub struct GetInfoResult {
pub blockheight: i32,
pub sync: f64,
pub descriptors: GetInfoDescriptors,
/// The progress as a percentage (between 0 and 1) of an ongoing rescan if there is any
pub rescan_progress: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]