Prefix in relay loops logs (#920)

* prefix in relay loops logs

* fmt
This commit is contained in:
Svyatoslav Nikolsky
2021-04-22 14:44:39 +03:00
committed by Bastian Köcher
parent 25a4151a8b
commit 63ce1b5973
14 changed files with 137 additions and 89 deletions
+9 -6
View File
@@ -26,7 +26,7 @@ use std::{
};
/// Transaction proof pipeline.
pub trait TransactionProofPipeline {
pub trait TransactionProofPipeline: 'static {
/// Name of the transaction proof source.
const SOURCE_NAME: &'static str;
/// Name of the transaction proof target.
@@ -35,18 +35,21 @@ pub trait TransactionProofPipeline {
/// Block type.
type Block: SourceBlock;
/// Transaction inclusion proof type.
type TransactionProof;
type TransactionProof: 'static + Send + Sync;
}
/// Block that is participating in exchange.
pub trait SourceBlock {
pub trait SourceBlock: 'static + Send + Sync {
/// Block hash type.
type Hash: Clone + Debug + Display;
type Hash: 'static + Clone + Send + Sync + Debug + Display;
/// Block number type.
type Number: Debug
type Number: 'static
+ Debug
+ Display
+ Clone
+ Copy
+ Send
+ Sync
+ Into<u64>
+ std::cmp::Ord
+ std::ops::Add<Output = Self::Number>
@@ -61,7 +64,7 @@ pub trait SourceBlock {
}
/// Transaction that is participating in exchange.
pub trait SourceTransaction {
pub trait SourceTransaction: 'static + Send {
/// Transaction hash type.
type Hash: Debug + Display;
+6 -6
View File
@@ -39,9 +39,9 @@ pub struct TransactionProofsRelayState<BlockNumber> {
}
/// Transactions proofs relay storage.
pub trait TransactionProofsRelayStorage: Clone {
pub trait TransactionProofsRelayStorage: 'static + Clone + Send + Sync {
/// Associated block number.
type BlockNumber;
type BlockNumber: 'static + Send + Sync;
/// Get relay state.
fn state(&self) -> TransactionProofsRelayState<Self::BlockNumber>;
@@ -64,7 +64,7 @@ impl<BlockNumber> InMemoryStorage<BlockNumber> {
}
}
impl<BlockNumber: Clone + Copy> TransactionProofsRelayStorage for InMemoryStorage<BlockNumber> {
impl<BlockNumber: 'static + Clone + Copy + Send + Sync> TransactionProofsRelayStorage for InMemoryStorage<BlockNumber> {
type BlockNumber = BlockNumber;
fn state(&self) -> TransactionProofsRelayState<BlockNumber> {
@@ -89,7 +89,7 @@ pub async fn run<P: TransactionProofPipeline>(
source_client: impl SourceClient<P>,
target_client: impl TargetClient<P>,
metrics_params: MetricsParams,
exit_signal: impl Future<Output = ()>,
exit_signal: impl Future<Output = ()> + 'static + Send,
) -> Result<(), String> {
let exit_signal = exit_signal.shared();
@@ -99,7 +99,7 @@ pub async fn run<P: TransactionProofPipeline>(
.standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))?
.expose()
.await?
.run(|source_client, target_client, metrics| {
.run(metrics_prefix::<P>(), move |source_client, target_client, metrics| {
run_until_connection_lost(
storage.clone(),
source_client,
@@ -117,7 +117,7 @@ async fn run_until_connection_lost<P: TransactionProofPipeline>(
source_client: impl SourceClient<P>,
target_client: impl TargetClient<P>,
metrics_exch: Option<ExchangeLoopMetrics>,
exit_signal: impl Future<Output = ()>,
exit_signal: impl Future<Output = ()> + Send,
) -> Result<(), FailedClient> {
let mut retry_backoff = retry_backoff();
let mut state = storage.state();