mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 04:07:57 +00:00
system_syncState: Always return highest block (#11979)
Before `highestBlock` was an optional that was omitted when it was `None`. We recently changed the way the `highestBlock` is determined, this resulted in having this value in 99.99% of the time being `None` when the node is syncing blocks at the tip. Now we always return a block for `highestBlock`. If sync doesn't return us any best seen block, we return our own local best block as `highestBlock`. This should mainly reflect the same behavior to before we changed the way the best seen block is determined.
This commit is contained in:
@@ -88,10 +88,10 @@ pub struct SyncState<Number> {
|
||||
pub starting_block: Number,
|
||||
/// Height of the current best block of the node.
|
||||
pub current_block: Number,
|
||||
/// Height of the highest block learned from the network. Missing if no block is known yet.
|
||||
#[serde(default = "Default::default", skip_serializing_if = "Option::is_none")]
|
||||
pub highest_block: Option<Number>,
|
||||
/// Height of the highest block in the network.
|
||||
pub highest_block: Number,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -129,7 +129,7 @@ mod tests {
|
||||
::serde_json::to_string(&SyncState {
|
||||
starting_block: 12u32,
|
||||
current_block: 50u32,
|
||||
highest_block: Some(128u32),
|
||||
highest_block: 128u32,
|
||||
})
|
||||
.unwrap(),
|
||||
r#"{"startingBlock":12,"currentBlock":50,"highestBlock":128}"#,
|
||||
@@ -139,10 +139,10 @@ mod tests {
|
||||
::serde_json::to_string(&SyncState {
|
||||
starting_block: 12u32,
|
||||
current_block: 50u32,
|
||||
highest_block: None,
|
||||
highest_block: 50u32,
|
||||
})
|
||||
.unwrap(),
|
||||
r#"{"startingBlock":12,"currentBlock":50}"#,
|
||||
r#"{"startingBlock":12,"currentBlock":50,"highestBlock":50}"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user