Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
samelamin committed Dec 19, 2022
1 parent d4d36cc commit 481a6ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
31 changes: 24 additions & 7 deletions client/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ use polkadot_primitives::v2::{
use codec::{Decode, DecodeAll, Encode};
use futures::{channel::oneshot, future::FutureExt, Future};
use std::{convert::TryFrom, fmt, marker::PhantomData, pin::Pin, sync::Arc};
use tokio::time::sleep;

#[cfg(test)]
mod tests;

Expand Down Expand Up @@ -453,20 +455,35 @@ async fn wait_to_announce<Block: BlockT>(
}
}

#[derive(Clone)]
pub struct WaitForParachainTargetBlock<Block> {
phantom: PhantomData<Block>,
}

pub async fn warp_sync_get<B>(
para_id: ParaId,
relay_chain_interface: Arc<dyn RelayChainInterface>,
spawner: Arc<dyn SpawnNamed + Send + Sync>,
) -> Result<oneshot::Receiver<<B as BlockT>::Header>, BoxedError>
where
B: BlockT + 'static,
{
let (sender, receiver) = oneshot::channel::<B::Header>();
wait_for_target_block::<B>(sender, para_id, relay_chain_interface).await?;
spawner.spawn(
"cumulus-parachain-wait-for-target-block",
None,
async move {
tracing::debug!(
target: "cumulus-network",
"waiting for announce block in a background task...",
);
tracing::debug!(target: LOG_TARGET, "waiting for target block in a background task...",);
wait_for_target_block::<B>(sender, para_id, relay_chain_interface)
.await
.map_err(|e| {
tracing::error!(target: LOG_TARGET, "Unable to determine sync status. {}", e)
})
.unwrap();
tracing::debug!(target: LOG_TARGET, "target block reached",);
}
.boxed(),
);

return Ok(receiver)
}

Expand Down Expand Up @@ -519,7 +536,7 @@ where
return Ok(())
}
tracing::info!(target: LOG_TARGET, "waiting for relay chain sync to complete......",);
tokio::time::sleep(std::time::Duration::from_secs(120)).await;
sleep(std::time::Duration::from_secs(120)).await;
},
_ => return Ok(()),
}
Expand Down
1 change: 1 addition & 0 deletions client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ where
let warp_sync_params = if let Ok(target_block) = cumulus_client_network::warp_sync_get::<Block>(
para_id,
Arc::new(relay_chain_interface.clone()),
Arc::new(task_manager.spawn_handle()),
)
.await
{
Expand Down

0 comments on commit 481a6ff

Please sign in to comment.