According to the example here, I see one could use the srml_support::storage::child
API to create a merkle sub trie out of arbitrary data. But how can we get the merkle root or a proof for a particular leaf using this? I see the API doesn't provide any functions named as such.
The srml_support::storage::child
API make use of sr_io
API.
sr_io
provides more functionality, for example sr_io::child_storage_root which is the function you are looking for.
An alternative is to directly query the parent trie node containing the root. For the linked exemple it will be something like this (child_storage_root is doing calculation of ongoing change whereas querying directly the root get the state at the start of the block processing or the latest stored state calculation):
let id = Self::id_from_index(index);
let child_root = storage::unhashed::get_raw(id.as_ref());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With