mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
Light client friendly events (#2491)
* Sketch of indexed events. * Get EventIndex by holding another variable. * Add some docs. * Use DoubleMap to store reverse topic index * Implement StorageDoubleMap::append * Use append for EventTopics. * Refactor. * Avoid `mutate` * Docs. * Add topics to EventRecord * Update tests. * Rebuild. * Bump version. * Event topics test. * Mix in BlockNumber to distinguish updates * Fix srml-system test. * Post merge fixes. * Comments/TODO.
This commit is contained in:
committed by
Gavin Wood
parent
d974189e3c
commit
21773b3a07
@@ -238,6 +238,7 @@ mod tests {
|
||||
pub DataDM config(test_config) build(|_| vec![(15u32, 16u32, 42u64)]): double_map hasher(twox_64_concat) u32, blake2_256(u32) => u64;
|
||||
pub GenericDataDM: double_map T::BlockNumber, twox_128(T::BlockNumber) => T::BlockNumber;
|
||||
pub GenericData2DM: double_map T::BlockNumber, twox_256(T::BlockNumber) => Option<T::BlockNumber>;
|
||||
pub AppendableDM: double_map u32, blake2_256(T::BlockNumber) => Vec<u32>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +368,21 @@ mod tests {
|
||||
assert_eq!(DoubleMap::get(key1, key2+1), 0u64);
|
||||
assert_eq!(DoubleMap::get(key1+1, key2), 4u64);
|
||||
assert_eq!(DoubleMap::get(key1+1, key2+1), 4u64);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn double_map_append_should_work() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
type DoubleMap = AppendableDM<Test>;
|
||||
|
||||
let key1 = 17u32;
|
||||
let key2 = 18u32;
|
||||
|
||||
DoubleMap::insert(key1, key2, vec![1]);
|
||||
DoubleMap::append(key1, key2, &[2, 3]);
|
||||
assert_eq!(DoubleMap::get(key1, key2), vec![1, 2, 3]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -453,6 +469,21 @@ mod tests {
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageFunctionMetadata {
|
||||
name: DecodeDifferent::Encode("AppendableDM"),
|
||||
modifier: StorageFunctionModifier::Default,
|
||||
ty: StorageFunctionType::DoubleMap{
|
||||
hasher: StorageHasher::Blake2_256,
|
||||
key1: DecodeDifferent::Encode("u32"),
|
||||
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
||||
value: DecodeDifferent::Encode("Vec<u32>"),
|
||||
key2_hasher: DecodeDifferent::Encode("blake2_256"),
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::<Test>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
])
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user