Add pluggable BEEFY payload constructors (#12428)

* primitives/beefy: move Payload to its own file

* primitives/beefy: add Payload tests

* primitives/beefy: add MmrRootProvider as custom BEEFY payload provider

* client/beefy: use generic BEEFY 'PayloadProvider'

* primitives/beefy: rename Payload::new to Payload::from_single_entry for clarity

* fix visibility

* fix cargo doc
This commit is contained in:
Adrian Catangiu
2022-10-06 12:20:27 +03:00
committed by GitHub
parent 261c5fd6dd
commit b91d2dfdc1
13 changed files with 284 additions and 151 deletions
+4 -1
View File
@@ -38,6 +38,7 @@ use sc_utils::notification::NotificationReceiver;
use beefy_primitives::{
crypto::{AuthorityId, Signature},
mmr::MmrRootProvider,
BeefyApi, ConsensusLog, MmrRootHash, ValidatorSet, VersionedFinalityProof, BEEFY_ENGINE_ID,
KEY_TYPE as BeefyKeyType,
};
@@ -372,10 +373,12 @@ where
justifications_protocol_name: on_demand_justif_handler.protocol_name(),
_phantom: PhantomData,
};
let payload_provider = MmrRootProvider::new(api.clone());
let beefy_params = crate::BeefyParams {
client: peer.client().as_client(),
backend: peer.client().as_backend(),
payload_provider,
runtime: api.clone(),
key_store: Some(keystore),
network_params,
@@ -384,7 +387,7 @@ where
prometheus_registry: None,
on_demand_justifications_handler: on_demand_justif_handler,
};
let task = crate::start_beefy_gadget::<_, _, _, _, _>(beefy_params);
let task = crate::start_beefy_gadget::<_, _, _, _, _, _>(beefy_params);
fn assert_send<T: Send>(_: &T) {}
assert_send(&task);