ProposerFactory impl Clone (#3389)

In Tanssi, we need a way to stop the collator code and then start it
again. This is to support rotating the same collator between different
runtimes. Currently, this works very well, except for the proposer
metrics, because they only get registered the first time they are
started. Afterwards, we see this warning log:

> Failed to register proposer prometheus metrics: Duplicate metrics
collector registration attempted


~~So this PR adds a method to set metrics, to allow us to register
metrics manually before creating the `ProposerFactory`, and then clone
the same metrics every time we need to start the collator.~~ Implemented
Clone instead
This commit is contained in:
tmpolaczyk
2024-02-21 17:38:06 +01:00
committed by GitHub
parent 1b624c5072
commit 318fed32f8
@@ -87,6 +87,22 @@ pub struct ProposerFactory<A, C, PR> {
_phantom: PhantomData<PR>,
}
impl<A, C, PR> Clone for ProposerFactory<A, C, PR> {
fn clone(&self) -> Self {
Self {
spawn_handle: self.spawn_handle.clone(),
client: self.client.clone(),
transaction_pool: self.transaction_pool.clone(),
metrics: self.metrics.clone(),
default_block_size_limit: self.default_block_size_limit,
soft_deadline_percent: self.soft_deadline_percent,
telemetry: self.telemetry.clone(),
include_proof_in_block_size_estimation: self.include_proof_in_block_size_estimation,
_phantom: self._phantom,
}
}
}
impl<A, C> ProposerFactory<A, C, DisableProofRecording> {
/// Create a new proposer factory.
///