mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +00:00
Use TypedLaneId instead of LaneId (#1738)
* TypedLaneId -> LaneId * fix benchmarks compilation
This commit is contained in:
committed by
Bastian Köcher
parent
41daa32acb
commit
03425b33ae
@@ -67,16 +67,30 @@ impl OperatingMode for MessagesOperatingMode {
|
||||
}
|
||||
}
|
||||
|
||||
/// Lane identifier.
|
||||
pub type LaneId = [u8; 4];
|
||||
|
||||
/// Lane id which implements `TypeId`.
|
||||
// TODO (https://github.com/paritytech/parity-bridges-common/issues/1694):
|
||||
// `LaneId` shall be replaced with this across all codebase (codec-compatible)
|
||||
#[derive(Decode, Encode, RuntimeDebug)]
|
||||
pub struct TypedLaneId(pub [u8; 4]);
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Decode,
|
||||
Default,
|
||||
Encode,
|
||||
Eq,
|
||||
Ord,
|
||||
PartialOrd,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
TypeInfo,
|
||||
MaxEncodedLen,
|
||||
)]
|
||||
pub struct LaneId(pub [u8; 4]);
|
||||
|
||||
impl TypeId for TypedLaneId {
|
||||
impl AsRef<[u8]> for LaneId {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeId for LaneId {
|
||||
const TYPE_ID: [u8; 4] = *b"blan";
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ pub fn outbound_lane_data_key(pallet_prefix: &str, lane: &LaneId) -> StorageKey
|
||||
bp_runtime::storage_map_final_key::<Blake2_128Concat>(
|
||||
pallet_prefix,
|
||||
OUTBOUND_LANES_MAP_NAME,
|
||||
lane,
|
||||
&lane.encode(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ pub fn inbound_lane_data_key(pallet_prefix: &str, lane: &LaneId) -> StorageKey {
|
||||
bp_runtime::storage_map_final_key::<Blake2_128Concat>(
|
||||
pallet_prefix,
|
||||
INBOUND_LANES_MAP_NAME,
|
||||
lane,
|
||||
&lane.encode(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ mod tests {
|
||||
fn storage_message_key_computed_properly() {
|
||||
// If this test fails, then something has been changed in module storage that is breaking
|
||||
// all previously crafted messages proofs.
|
||||
let storage_key = message_key("BridgeMessages", b"test", 42).0;
|
||||
let storage_key = message_key("BridgeMessages", &LaneId(*b"test"), 42).0;
|
||||
assert_eq!(
|
||||
storage_key,
|
||||
hex!("dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000").to_vec(),
|
||||
@@ -104,7 +104,7 @@ mod tests {
|
||||
fn outbound_lane_data_key_computed_properly() {
|
||||
// If this test fails, then something has been changed in module storage that is breaking
|
||||
// all previously crafted outbound lane state proofs.
|
||||
let storage_key = outbound_lane_data_key("BridgeMessages", b"test").0;
|
||||
let storage_key = outbound_lane_data_key("BridgeMessages", &LaneId(*b"test")).0;
|
||||
assert_eq!(
|
||||
storage_key,
|
||||
hex!("dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374").to_vec(),
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
fn inbound_lane_data_key_computed_properly() {
|
||||
// If this test fails, then something has been changed in module storage that is breaking
|
||||
// all previously crafted inbound lane state proofs.
|
||||
let storage_key = inbound_lane_data_key("BridgeMessages", b"test").0;
|
||||
let storage_key = inbound_lane_data_key("BridgeMessages", &LaneId(*b"test")).0;
|
||||
assert_eq!(
|
||||
storage_key,
|
||||
hex!("dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374").to_vec(),
|
||||
|
||||
Reference in New Issue
Block a user