explorer bootstrap: replace Future::wait with block_on from tokio_compat
@@ -143,6 +143,14 @@ impl ExplorerDB {
/// Blockchain settings from the Block0 (Discrimination)
/// This function is only called once on the node's bootstrap phase
pub fn bootstrap(block0: Block, blockchain: &Blockchain) -> Result<Self> {
+ use tokio_compat::runtime;
+
+ let mut rt = runtime::Builder::new()
+ .name_prefix("explorer-bootstrap-worker-")
+ .core_threads(1)
+ .build()
+ .unwrap();
+
let blockchain_config = BlockchainConfig::from_config_params(
block0
.contents
@@ -181,9 +189,7 @@ impl ExplorerDB {
};
let multiverse = Multiverse::<State>::new();
- multiverse
- .insert(block0.chain_length(), block0.id(), initial_state)
- .wait()
+ rt.block_on(multiverse.insert(block0.chain_length(), block0.id(), initial_state))
.expect("The multiverse to be empty");
let block0_id = block0.id().clone();
@@ -198,6 +204,7 @@ impl ExplorerDB {
blockchain: blockchain.clone(),
};
+ rt.block_on(
blockchain
.storage()
.get_tag(MAIN_BRANCH_TAG.to_owned())
@@ -219,8 +226,8 @@ impl ExplorerDB {
.fold(bootstraped_db, |mut db, block| {
db.apply_block(block).and_then(|_gc_root| Ok(db))
})
- })
- .wait()
+ }),
+ )
}
/// Try to add a new block to the indexes, this can fail if the parent of the block is
