Skip to content

Commit

Permalink
Merge pull request #1862 from EspressoSystems/bf/poll-view-sync
Browse files Browse the repository at this point in the history
Subscribe to web server when starting view sync
  • Loading branch information
bfish713 authored Oct 4, 2023
2 parents d4cb5d0 + 517c688 commit 5e848f9
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions crates/task-impls/src/view_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,20 @@ where
}

// We do not have a replica task already running, so start one
let mut replica_state = ViewSyncReplicaTaskState {
current_view: certificate_internal.round,
next_view: certificate_internal.round,
relay: 0,
finalized: false,
sent_view_change_event: false,
phase: ViewSyncPhase::None,
exchange: self.exchange.clone(),
api: self.api.clone(),
event_stream: self.event_stream.clone(),
view_sync_timeout: self.view_sync_timeout,
id: self.id,
};
let mut replica_state: ViewSyncReplicaTaskState<TYPES, I, A> =
ViewSyncReplicaTaskState {
current_view: certificate_internal.round,
next_view: certificate_internal.round,
relay: 0,
finalized: false,
sent_view_change_event: false,
phase: ViewSyncPhase::None,
exchange: self.exchange.clone(),
api: self.api.clone(),
event_stream: self.event_stream.clone(),
view_sync_timeout: self.view_sync_timeout,
id: self.id,
};

let result = replica_state.handle_event(event.clone()).await;

Expand Down Expand Up @@ -514,10 +515,29 @@ where
.await;
// panic!("Starting view sync!");
// Spawn replica task
let next_view = *view_number + 1;
// Subscribe to the next view just in case there is progress being made
self.exchange
.network()
.inject_consensus_info(ConsensusIntentEvent::PollForProposal(next_view))
.await;

self.exchange
.network()
.inject_consensus_info(ConsensusIntentEvent::PollForDAC(next_view))
.await;

if self.exchange.is_leader(TYPES::Time::new(next_view + 1)) {
debug!("Polling for quorum votes for view {}", next_view);
self.exchange
.network()
.inject_consensus_info(ConsensusIntentEvent::PollForVotes(next_view))
.await;
}

let mut replica_state = ViewSyncReplicaTaskState {
current_view: self.current_view,
next_view: TYPES::Time::new(*view_number + 1),
next_view: TYPES::Time::new(next_view),
relay: 0,
finalized: false,
sent_view_change_event: false,
Expand Down

0 comments on commit 5e848f9

Please sign in to comment.