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 20, 2022
1 parent aa72d6d commit ba287fa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
2 changes: 1 addition & 1 deletion client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use polkadot_primitives::v2::CollatorPair;
use sc_client_api::{
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, ProofProvider, UsageProvider,
};
use sc_service::{Configuration, TaskManager};
use sc_telemetry::TelemetryWorkerHandle;

use sc_consensus::{import_queue::ImportQueueService, BlockImport, ImportQueue};
Expand Down Expand Up @@ -323,6 +322,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 ba287fa

Please sign in to comment.