Skip to content

Commit

Permalink
Tiny refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Dec 24, 2023
1 parent bc2844b commit b6b1fcf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/sc-consensus-subspace-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,18 +649,19 @@ where
fn subscribe_node_sync_status_change(&self, mut sink: SubscriptionSink) -> SubscriptionResult {
let sync_oracle = self.sync_oracle.clone();
let fut = async move {
let mut last_node_sync_status = None;
let mut last_is_major_syncing = None;
loop {
let node_sync_status = if sync_oracle.is_major_syncing() {
NodeSyncStatus::MajorSyncing
} else {
NodeSyncStatus::Synced
};
let is_major_syncing = sync_oracle.is_major_syncing();

// Update subscriber if value has changed
if last_node_sync_status != Some(node_sync_status) {
last_node_sync_status.replace(node_sync_status);
if last_is_major_syncing != Some(is_major_syncing) {
last_is_major_syncing.replace(is_major_syncing);

let node_sync_status = if is_major_syncing {
NodeSyncStatus::MajorSyncing
} else {
NodeSyncStatus::Synced
};
match sink.send(&node_sync_status) {
Ok(true) => {
// Success
Expand Down

0 comments on commit b6b1fcf

Please sign in to comment.