Skip to content

Commit

Permalink
Move template notif to after resolve_virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofstuff committed Nov 7, 2023
1 parent a153a7c commit e9327dd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
7 changes: 5 additions & 2 deletions consensus/src/pipeline/virtual_processor/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ use kaspa_consensus_core::{
};
use kaspa_consensus_notify::{
notification::{
Notification, SinkBlueScoreChangedNotification, UtxosChangedNotification, VirtualChainChangedNotification,
VirtualDaaScoreChangedNotification,
NewBlockTemplateNotification, Notification, SinkBlueScoreChangedNotification, UtxosChangedNotification,
VirtualChainChangedNotification, VirtualDaaScoreChangedNotification,
},
root::ConsensusNotificationRoot,
};
Expand Down Expand Up @@ -301,6 +301,9 @@ impl VirtualStateProcessor {
// Emit notifications
let accumulated_diff = Arc::new(accumulated_diff);
let virtual_parents = Arc::new(new_virtual_state.parents.clone());
self.notification_root
.notify(Notification::NewBlockTemplate(NewBlockTemplateNotification {}))
.expect("expecting an open unbounded channel");
self.notification_root
.notify(Notification::UtxosChanged(UtxosChangedNotification::new(accumulated_diff, virtual_parents)))
.expect("expecting an open unbounded channel");
Expand Down
10 changes: 1 addition & 9 deletions protocol/flows/src/flow_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use kaspa_consensus_core::config::Config;
use kaspa_consensus_core::errors::block::RuleError;
use kaspa_consensus_core::tx::{Transaction, TransactionId};
use kaspa_consensus_notify::{
notification::{NewBlockTemplateNotification, Notification, PruningPointUtxoSetOverrideNotification},
notification::{Notification, PruningPointUtxoSetOverrideNotification},
root::ConsensusNotificationRoot,
};
use kaspa_consensusmanager::{ConsensusInstance, ConsensusManager, ConsensusProxy};
Expand Down Expand Up @@ -375,7 +375,6 @@ impl FlowContext {
self.hub.broadcast(make_message!(Payload::InvRelayBlock, InvRelayBlockMessage { hash: Some(hash.into()) })).await;

self.on_new_block(consensus, block, virtual_state_task).await;
self.on_new_block_template().await;
self.log_block_acceptance(hash, BlockSource::Submit);

Ok(())
Expand Down Expand Up @@ -463,13 +462,6 @@ impl FlowContext {
}
}

/// Notifies that a new block template is available for miners.
pub async fn on_new_block_template(&self) {
// Notifications from the flow context might be ignored if the inner channel is already closing
// due to global shutdown, hence we ignore the possible error
let _ = self.notification_root.notify(Notification::NewBlockTemplate(NewBlockTemplateNotification {}));
}

/// Notifies that the UTXO set was reset due to pruning point change via IBD.
pub fn on_pruning_point_utxoset_override(&self) {
// Notifications from the flow context might be ignored if the inner channel is already closing
Expand Down
1 change: 0 additions & 1 deletion protocol/flows/src/v5/blockrelay/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ impl HandleRelayInvsFlow {
let ctx = self.ctx.clone();
tokio::spawn(async move {
ctx.on_new_block(&session, block, virtual_state_task).await;
ctx.on_new_block_template().await;
ctx.log_block_acceptance(inv.hash, BlockSource::Relay);
});
}
Expand Down
2 changes: 0 additions & 2 deletions protocol/flows/src/v5/ibd/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ staging selected tip ({}) is too small or negative. Aborting IBD...",
try_join_all(prev_jobs).await?;
progress_reporter.report_completion(prev_chunk_len);

self.ctx.on_new_block_template().await;

Ok(())
}

Expand Down

0 comments on commit e9327dd

Please sign in to comment.