Skip to content

Commit

Permalink
jormungandr: remove explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Nov 29, 2021
1 parent 35fc7c4 commit 508d153
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 2,662 deletions.
1 change: 0 additions & 1 deletion jormungandr/src/blockchain/bootstrap.rs
Expand Up @@ -42,7 +42,6 @@ where
blockchain.clone(),
None,
None,
None,
Metrics::builder().build(),
);

Expand Down
41 changes: 4 additions & 37 deletions jormungandr/src/blockchain/process.rs
Expand Up @@ -7,7 +7,7 @@ use super::{
use crate::{
blockcfg::{Block, Header, HeaderHash},
blockchain::Checkpoints,
intercom::{self, BlockMsg, ExplorerMsg, NetworkMsg, PropagateMsg, TransactionMsg, WatchMsg},
intercom::{self, BlockMsg, NetworkMsg, PropagateMsg, TransactionMsg, WatchMsg},
metrics::{Metrics, MetricsBackend},
network::p2p::Address,
utils::{
Expand Down Expand Up @@ -56,7 +56,6 @@ pub struct TaskData {
pub stats_counter: Metrics,
pub network_msgbox: MessageBox<NetworkMsg>,
pub fragment_msgbox: MessageBox<TransactionMsg>,
pub explorer_msgbox: Option<MessageBox<ExplorerMsg>>,
pub watch_msgbox: MessageBox<WatchMsg>,
pub garbage_collection_interval: Duration,
}
Expand All @@ -74,7 +73,6 @@ struct Process {
stats_counter: Metrics,
network_msgbox: MessageBox<NetworkMsg>,
fragment_msgbox: MessageBox<TransactionMsg>,
explorer_msgbox: Option<MessageBox<ExplorerMsg>>,
watch_msgbox: MessageBox<WatchMsg>,
garbage_collection_interval: Duration,
tip_update_mbox: MessageBox<Arc<Ref>>,
Expand Down Expand Up @@ -145,7 +143,6 @@ pub async fn start(
stats_counter,
network_msgbox,
fragment_msgbox,
explorer_msgbox,
garbage_collection_interval,
watch_msgbox,
} = task_data;
Expand All @@ -162,7 +159,6 @@ pub async fn start(
stats_counter,
network_msgbox,
fragment_msgbox,
explorer_msgbox,
watch_msgbox,
garbage_collection_interval,
tip_update_mbox,
Expand All @@ -186,7 +182,6 @@ impl Process {
self.blockchain_tip.clone(),
self.blockchain.clone(),
Some(self.fragment_msgbox.clone()),
self.explorer_msgbox.clone(),
Some(self.watch_msgbox.clone()),
self.stats_counter.clone(),
);
Expand All @@ -204,7 +199,6 @@ impl Process {
let blockchain = self.blockchain.clone();
let blockchain_tip = self.blockchain_tip.clone();
let network_msg_box = self.network_msgbox.clone();
let explorer_msg_box = self.explorer_msgbox.clone();
let watch_msg_box = self.watch_msgbox.clone();
let stats_counter = self.stats_counter.clone();
tracing::trace!("handling new blockchain task item");
Expand All @@ -228,7 +222,6 @@ impl Process {
blockchain,
self.tip_update_mbox.clone(),
network_msg_box,
explorer_msg_box,
watch_msg_box,
leadership_block,
)
Expand Down Expand Up @@ -278,7 +271,6 @@ impl Process {
self.blockchain.clone(),
self.tip_update_mbox.clone(),
network_msg_box,
explorer_msg_box,
watch_msg_box,
self.get_next_block_scheduler.clone(),
handle,
Expand Down Expand Up @@ -362,7 +354,6 @@ async fn process_leadership_block(
mut blockchain: Blockchain,
tip_update_mbox: MessageBox<Arc<Ref>>,
network_msg_box: MessageBox<NetworkMsg>,
explorer_msg_box: Option<MessageBox<ExplorerMsg>>,
mut watch_msg_box: MessageBox<WatchMsg>,
leadership_block: LeadershipBlock,
) -> chain::Result<()> {
Expand All @@ -373,10 +364,6 @@ async fn process_leadership_block(
.send(WatchMsg::NewBlock(block.clone()))
.await?;

if let Some(mut msg_box) = explorer_msg_box {
msg_box.send(ExplorerMsg::NewBlock(block)).await?;
}

process_and_propagate_new_ref(Arc::clone(&new_block_ref), tip_update_mbox, network_msg_box)
.await?;

Expand Down Expand Up @@ -448,7 +435,6 @@ async fn process_network_blocks(
blockchain: Blockchain,
tip_update_mbox: MessageBox<Arc<Ref>>,
network_msg_box: MessageBox<NetworkMsg>,
mut explorer_msg_box: Option<MessageBox<ExplorerMsg>>,
mut watch_msg_box: MessageBox<WatchMsg>,
mut get_next_block_scheduler: GetNextBlockScheduler,
handle: intercom::RequestStreamHandle<Block, ()>,
Expand All @@ -464,7 +450,6 @@ async fn process_network_blocks(
let res = process_network_block(
&blockchain,
block.clone(),
explorer_msg_box.as_mut(),
&mut watch_msg_box,
&mut get_next_block_scheduler,
)
Expand Down Expand Up @@ -513,7 +498,6 @@ async fn process_network_blocks(
async fn process_network_block(
blockchain: &Blockchain,
block: Block,
explorer_msg_box: Option<&mut MessageBox<ExplorerMsg>>,
watch_msg_box: &mut MessageBox<WatchMsg>,
get_next_block_scheduler: &mut GetNextBlockScheduler,
) -> Result<Option<Arc<Ref>>, chain::Error> {
Expand Down Expand Up @@ -544,14 +528,7 @@ async fn process_network_block(
Err(Error::MissingParentBlock(parent_hash))
}
PreCheckedHeader::HeaderWithCache { parent_ref, .. } => {
let r = check_and_apply_block(
blockchain,
parent_ref,
block,
explorer_msg_box,
watch_msg_box,
)
.await;
let r = check_and_apply_block(blockchain, parent_ref, block, watch_msg_box).await;
r
}
}
Expand All @@ -564,10 +541,8 @@ async fn check_and_apply_block(
blockchain: &Blockchain,
parent_ref: Arc<Ref>,
block: Block,
explorer_msg_box: Option<&mut MessageBox<ExplorerMsg>>,
watch_msg_box: &mut MessageBox<WatchMsg>,
) -> Result<Option<Arc<Ref>>, chain::Error> {
let explorer_enabled = explorer_msg_box.is_some();
let post_checked = blockchain
.post_check_header(
block.header().clone(),
Expand All @@ -576,22 +551,14 @@ async fn check_and_apply_block(
)
.await?;
tracing::debug!("applying block to storage");
let mut block_for_explorer = if explorer_enabled {
Some(block.clone())
} else {
None
};

let block_for_watchers = block.clone();

let applied_block = blockchain
.apply_and_store_block(post_checked, block)
.await?;
if let AppliedBlock::New(block_ref) = applied_block {
tracing::debug!("applied block to storage");
if let Some(msg_box) = explorer_msg_box {
msg_box
.try_send(ExplorerMsg::NewBlock(block_for_explorer.take().unwrap()))
.unwrap_or_else(|err| tracing::error!("cannot add block to explorer: {}", err));
}

watch_msg_box
.try_send(WatchMsg::NewBlock(block_for_watchers))
Expand Down
14 changes: 1 addition & 13 deletions jormungandr/src/blockchain/tip.rs
Expand Up @@ -4,7 +4,7 @@ use crate::{
chain_selection::{self, ComparisonResult},
storage, Blockchain, Branch, Error, Ref, MAIN_BRANCH_TAG,
},
intercom::{ExplorerMsg, TransactionMsg, WatchMsg},
intercom::{TransactionMsg, WatchMsg},
metrics::{Metrics, MetricsBackend},
utils::async_msg::{self, MessageBox, MessageQueue},
};
Expand All @@ -26,7 +26,6 @@ const BRANCH_REPROCESSING_INTERVAL: Duration = Duration::from_secs(60);
pub struct TipUpdater {
tip: Tip,
blockchain: Blockchain,
explorer_mbox: Option<MessageBox<ExplorerMsg>>,
watch_mbox: Option<MessageBox<WatchMsg>>,
fragment_mbox: Option<MessageBox<TransactionMsg>>,
stats_counter: Metrics,
Expand All @@ -37,15 +36,13 @@ impl TipUpdater {
tip: Tip,
blockchain: Blockchain,
fragment_mbox: Option<MessageBox<TransactionMsg>>,
explorer_mbox: Option<MessageBox<ExplorerMsg>>,
watch_mbox: Option<MessageBox<WatchMsg>>,
stats_counter: Metrics,
) -> Self {
Self {
tip,
blockchain,
fragment_mbox,
explorer_mbox,
watch_mbox,
stats_counter,
}
Expand Down Expand Up @@ -172,15 +169,6 @@ impl TipUpdater {
}

self.stats_counter.set_tip_block(&block, &candidate);
if let Some(ref mut msg_box) = self.explorer_mbox {
tracing::debug!("sending new tip to explorer {}", candidate_hash);
msg_box
.send(ExplorerMsg::NewTip(candidate_hash))
.await
.unwrap_or_else(|err| {
tracing::error!("cannot send new tip to explorer: {}", err)
});
}

if let Some(ref mut msg_box) = self.watch_mbox {
tracing::debug!("sending new tip to watch subscribers {}", candidate_hash);
Expand Down

0 comments on commit 508d153

Please sign in to comment.