Add is_optimistic
to eth/v1/node/syncing
response (#3374)
## Issue Addressed As specified in the [Beacon Chain API specs](https://github.com/ethereum/beacon-APIs/blob/master/apis/node/syncing.yaml#L32-L35) we should return `is_optimistic` as part of the response to a query for the `eth/v1/node/syncing` endpoint. ## Proposed Changes Compute the optimistic status of the head and add it to the `SyncingData` response.
This commit is contained in:
parent
904dd62524
commit
d316305411
@ -1852,8 +1852,13 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
// Taking advantage of saturating subtraction on slot.
|
// Taking advantage of saturating subtraction on slot.
|
||||||
let sync_distance = current_slot - head_slot;
|
let sync_distance = current_slot - head_slot;
|
||||||
|
|
||||||
|
let is_optimistic = chain
|
||||||
|
.is_optimistic_head()
|
||||||
|
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||||
|
|
||||||
let syncing_data = api_types::SyncingData {
|
let syncing_data = api_types::SyncingData {
|
||||||
is_syncing: network_globals.sync_state.read().is_syncing(),
|
is_syncing: network_globals.sync_state.read().is_syncing(),
|
||||||
|
is_optimistic,
|
||||||
head_slot,
|
head_slot,
|
||||||
sync_distance,
|
sync_distance,
|
||||||
};
|
};
|
||||||
|
@ -1281,6 +1281,7 @@ impl ApiTester {
|
|||||||
|
|
||||||
let expected = SyncingData {
|
let expected = SyncingData {
|
||||||
is_syncing: false,
|
is_syncing: false,
|
||||||
|
is_optimistic: false,
|
||||||
head_slot,
|
head_slot,
|
||||||
sync_distance,
|
sync_distance,
|
||||||
};
|
};
|
||||||
|
@ -552,6 +552,7 @@ pub struct VersionData {
|
|||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct SyncingData {
|
pub struct SyncingData {
|
||||||
pub is_syncing: bool,
|
pub is_syncing: bool,
|
||||||
|
pub is_optimistic: bool,
|
||||||
pub head_slot: Slot,
|
pub head_slot: Slot,
|
||||||
pub sync_distance: Slot,
|
pub sync_distance: Slot,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user