Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rm/remove-cancelled-p…
Browse files Browse the repository at this point in the history
…olls
  • Loading branch information
rob-maron committed Dec 14, 2023
2 parents 38c87d7 + 3bce45b commit 6373b81
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
35 changes: 22 additions & 13 deletions crates/hotshot/src/traits/networking/web_server_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ struct Inner<TYPES: NodeType> {
view_sync_vote_task_map: Arc<RwLock<TaskMap<TYPES::SignatureKey>>>,
/// Task map for transactions
txn_task_map: Arc<RwLock<TaskMap<TYPES::SignatureKey>>>,
/// Task polling for current propsal
current_proposal_task: Arc<RwLock<TaskMap<TYPES::SignatureKey>>>,
}

impl<TYPES: NodeType> Inner<TYPES> {
Expand Down Expand Up @@ -569,6 +571,7 @@ impl<TYPES: NodeType + 'static> WebServerNetwork<TYPES> {
view_sync_cert_task_map: Arc::default(),
view_sync_vote_task_map: Arc::default(),
txn_task_map: Arc::default(),
current_proposal_task: Arc::default(),
});

inner.connected.store(true, Ordering::Relaxed);
Expand Down Expand Up @@ -905,23 +908,29 @@ impl<TYPES: NodeType + 'static> ConnectedNetwork<Message<TYPES>, TYPES::Signatur
.await;
}
ConsensusIntentEvent::PollForCurrentProposal => {
// create new task
let (_, receiver) = unbounded();

async_spawn({
let inner_clone = self.inner.clone();
async move {
if let Err(e) = inner_clone
.poll_web_server(receiver, MessagePurpose::CurrentProposal, 1)
.await
{
warn!(
let mut proposal_task = self.inner.current_proposal_task.write().await;
if proposal_task.is_none() {
// create new task
let (sender, receiver) = unbounded();
*proposal_task = Some(sender);

async_spawn({
let inner_clone = self.inner.clone();
async move {
if let Err(e) = inner_clone
.poll_web_server(receiver, MessagePurpose::CurrentProposal, 1)
.await
{
warn!(
"Background receive proposal polling encountered an error: {:?}",
e
);
}
let mut proposal_task = inner_clone.current_proposal_task.write().await;
*proposal_task = None;
}
}
});
});
}
}
ConsensusIntentEvent::PollForVotes(view_number) => {
let mut task_map = self.inner.vote_task_map.write().await;
Expand Down
4 changes: 4 additions & 0 deletions crates/task-impls/src/view_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, A: ConsensusApi<TYPES, I> +
&& relay == self.relay
&& last_seen_certificate == self.phase
{
// Keep tyring to get a more recent proposal to catch up to
self.network
.inject_consensus_info(ConsensusIntentEvent::PollForCurrentProposal)
.await;
self.relay += 1;
match self.phase {
ViewSyncPhase::None => {
Expand Down

0 comments on commit 6373b81

Please sign in to comment.