commands: return last poll timestamp from getinfo

This commit is contained in:
Michael Mallan 2024-10-10 14:35:50 +01:00
parent c6add0aeb1
commit 0f9f1f352c
No known key found for this signature in database
GPG Key ID: 5177CDCEDB0EABEB
3 changed files with 18 additions and 9 deletions

View File

@ -53,15 +53,16 @@ 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` |
| `block_height` | 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 |
| `timestamp` | integer | Unix timestamp of wallet creation date |
| Field | Type | Description |
| -------------------- | --------------- | -------------------------------------------------------------------------------------------- |
| `version` | string | Version following the [SimVer](http://www.simver.org/) format |
| `network` | string | Answer can be `mainnet`, `testnet`, `regtest` |
| `block_height` | 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 |
| `timestamp` | integer | Unix timestamp of wallet creation date |
| `last_poll_timestamp`| integer or null | Unix timestamp of last poll (if any) of the blockchain |
### `getnewaddress`

View File

@ -324,6 +324,7 @@ impl DaemonControl {
},
rescan_progress,
timestamp: db_conn.timestamp(),
last_poll_timestamp: db_conn.last_poll_timestamp(),
}
}
@ -1127,6 +1128,8 @@ pub struct GetInfoResult {
pub rescan_progress: Option<f64>,
/// Timestamp at wallet creation date
pub timestamp: u32,
/// Timestamp of last poll, if any.
pub last_poll_timestamp: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -31,6 +31,11 @@ def test_getinfo(lianad):
assert res["sync"] == 1.0
assert "main" in res["descriptors"]
assert res["rescan_progress"] is None
last_poll_timestamp = res["last_poll_timestamp"]
assert last_poll_timestamp is not None
time.sleep(lianad.poll_interval_secs + 1)
res = lianad.rpc.getinfo()
assert res["last_poll_timestamp"] > last_poll_timestamp
def test_getaddress(lianad):