Skip to content

Commit

Permalink
set tip to MAIN_BRANCH_TAG when bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Jan 27, 2021
1 parent 6acd006 commit b11edda
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions jormungandr/src/explorer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,19 @@ impl ExplorerDB {

let block0_id = block0.id();

let maybe_head = blockchain.storage().get_tag(MAIN_BRANCH_TAG)?;
let (stream, hash) = match maybe_head {
Some(head) => (blockchain.storage().stream_from_to(block0_id, head)?, head),
None => {
return Err(Error::from(ErrorKind::BootstrapError(
"Couldn't read the HEAD tag from storage".to_owned(),
)))
}
};

let bootstraped_db = ExplorerDB {
multiverse,
longest_chain_tip: Tip::new(block0.header.id()),
longest_chain_tip: Tip::new(hash),
blockchain_config,
blockchain: blockchain.clone(),
blockchain_tip,
Expand All @@ -225,16 +235,6 @@ impl ExplorerDB {
},
};

let maybe_head = blockchain.storage().get_tag(MAIN_BRANCH_TAG)?;
let stream = match maybe_head {
Some(head) => blockchain.storage().stream_from_to(block0_id, head)?,
None => {
return Err(Error::from(ErrorKind::BootstrapError(
"Couldn't read the HEAD tag from storage".to_owned(),
)))
}
};

let db = stream
.map_err(Error::from)
.try_fold(bootstraped_db, |db, block| async move {
Expand Down

0 comments on commit b11edda

Please sign in to comment.