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:
Sergei Pepyakin
2019-05-13 20:56:01 +02:00
committed by Gavin Wood
parent d974189e3c
commit 21773b3a07
8 changed files with 325 additions and 56 deletions
+28
View File
@@ -401,6 +401,20 @@ pub trait StorageDoubleMap<K1: Codec, K2: Codec, V: Codec> {
KArg1: Borrow<K1>,
KArg2: Borrow<K2>,
F: FnOnce(&mut Self::Query) -> R;
/// Append the given items to the value under the key specified.
///
/// `V` is required to implement `codec::EncodeAppend<Item=I>`.
fn append<KArg1, KArg2, I>(
k1: KArg1,
k2: KArg2,
items: &[I],
) -> Result<(), &'static str>
where
KArg1: Borrow<K1>,
KArg2: Borrow<K2>,
I: codec::Encode,
V: EncodeAppend<Item=I>;
}
impl<K1: Codec, K2: Codec, V: Codec, U> StorageDoubleMap<K1, K2, V> for U
@@ -453,6 +467,20 @@ where
{
U::mutate(k1.borrow(), k2.borrow(), f, &RuntimeStorage)
}
fn append<KArg1, KArg2, I>(
k1: KArg1,
k2: KArg2,
items: &[I],
) -> Result<(), &'static str>
where
KArg1: Borrow<K1>,
KArg2: Borrow<K2>,
I: codec::Encode,
V: EncodeAppend<Item=I>,
{
U::append(k1.borrow(), k2.borrow(), items, &RuntimeStorage)
}
}
/// child storage NOTE could replace unhashed by having only one kind of storage (root being null storage