Parachain loop metrics (#1484)

* parachain loop metrics

* some fixes

* mini refactoring

* add tests
This commit is contained in:
Svyatoslav Nikolsky
2022-06-29 15:58:19 +03:00
committed by Bastian Köcher
parent f8ff3c9142
commit d11d9fd0b7
7 changed files with 228 additions and 22 deletions
+17 -1
View File
@@ -56,7 +56,7 @@ pub fn parachain_head_storage_key_at_source(
/// Returns runtime storage key of best known parachain head at the target chain.
///
/// The head is stored by the `pallet-bridge-parachains` pallet in the `BestParaHeads` map.
pub fn parachain_head_storage_key_at_target(
pub fn best_parachain_head_hash_storage_key_at_target(
bridge_parachains_pallet_name: &str,
para_id: ParaId,
) -> StorageKey {
@@ -66,3 +66,19 @@ pub fn parachain_head_storage_key_at_target(
&para_id.encode(),
)
}
/// Returns runtime storage key of the parachain head with given hash at the target chain.
///
/// The head is stored by the `pallet-bridge-parachains` pallet in the `ImportedParaHeads` map.
pub fn imported_parachain_head_storage_key_at_target(
bridge_parachains_pallet_name: &str,
para_id: ParaId,
head_hash: ParaHash,
) -> StorageKey {
bp_runtime::storage_double_map_final_key::<Blake2_128Concat, Blake2_128Concat>(
bridge_parachains_pallet_name,
"ImportedParaHeads",
&para_id.encode(),
&head_hash.encode(),
)
}