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:
parent
7866ff46cf
commit
073cdd0a89
15
doc/API.md
15
doc/API.md
@ -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`
|
||||
|
||||
|
||||
@ -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)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user