mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Document more TODOs as tickets (#1418)
Went through the TODOs, removed a bunch, which are outdated or nothing more than a regular comment, documented a bunch more as actual tickets and made them FIXMEs and unified their structure (`FIXME #TICKETNO DESC` for local tickets, `FIXME: DESC LINK` for external tickets) for easier in-editor support. Further more remove unnecessary remarks and related old code that I noticed in that instance.
This commit is contained in:
committed by
GitHub
parent
d2cfd7b9dc
commit
15ae7cfef6
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Utility functions to interact with Substrate's Base-16 Modified Merkle Patricia tree ("trie").
|
||||
|
||||
// TODO: no_std
|
||||
// FIXME: no_std - https://github.com/paritytech/substrate/issues/1574
|
||||
|
||||
mod error;
|
||||
mod node_header;
|
||||
@@ -71,7 +71,7 @@ pub fn delta_trie_root<H: Hasher, I, A, B>(db: &mut HashDB<H>, mut root: H::Out,
|
||||
for (key, change) in delta {
|
||||
match change {
|
||||
Some(val) => trie.insert(key.as_ref(), val.as_ref())?,
|
||||
None => trie.remove(key.as_ref())?, // TODO: archive mode
|
||||
None => trie.remove(key.as_ref())?,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ pub fn child_delta_trie_root<H: Hasher, I, A, B>(_storage_key: &[u8], db: &mut H
|
||||
for (key, change) in delta {
|
||||
match change {
|
||||
Some(val) => trie.insert(key.as_ref(), val.as_ref())?,
|
||||
None => trie.remove(key.as_ref())?, // TODO: archive mode
|
||||
None => trie.remove(key.as_ref())?,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +95,14 @@ impl<H: Hasher> trie_db::NodeCodec<H> for NodeCodec<H> {
|
||||
vec![EMPTY_TRIE]
|
||||
}
|
||||
|
||||
// TODO: refactor this so that `partial` isn't already encoded with HPE. Should just be an `impl Iterator<Item=u8>`.
|
||||
// FIXME: refactor this so that `partial` isn't already encoded with HPE. Should just be an `impl Iterator<Item=u8>`.
|
||||
fn leaf_node(partial: &[u8], value: &[u8]) -> Vec<u8> {
|
||||
let mut output = partial_to_key(partial, LEAF_NODE_OFFSET, LEAF_NODE_BIG);
|
||||
value.encode_to(&mut output);
|
||||
output
|
||||
}
|
||||
|
||||
// TODO: refactor this so that `partial` isn't already encoded with HPE. Should just be an `impl Iterator<Item=u8>`.
|
||||
// FIXME: refactor this so that `partial` isn't already encoded with HPE. Should just be an `impl Iterator<Item=u8>`.
|
||||
fn ext_node(partial: &[u8], child: ChildReference<H::Out>) -> Vec<u8> {
|
||||
let mut output = partial_to_key(partial, EXTENSION_NODE_OFFSET, EXTENSION_NODE_BIG);
|
||||
match child {
|
||||
|
||||
@@ -67,34 +67,25 @@ impl trie_root::TrieStream for TrieStream {
|
||||
|
||||
fn append_leaf(&mut self, key: &[u8], value: &[u8]) {
|
||||
self.buffer.extend(fuse_nibbles_node(key, true));
|
||||
// OPTIMISATION: I'd like to do `hpe.encode_to(&mut self.buffer);` here; need an `impl<'a> Encode for impl Iterator<Item = u8> + 'a`?
|
||||
value.encode_to(&mut self.buffer);
|
||||
}
|
||||
fn begin_branch(&mut self, maybe_value: Option<&[u8]>, has_children: impl Iterator<Item = bool>) {
|
||||
// println!("[begin_branch] pushing BRANCH_NODE");
|
||||
self.buffer.extend(&branch_node(maybe_value.is_some(), has_children));
|
||||
// Push the value if one exists.
|
||||
if let Some(value) = maybe_value {
|
||||
value.encode_to(&mut self.buffer);
|
||||
}
|
||||
// println!("[begin_branch] buffer so far: {:#x?}", self.buffer);
|
||||
}
|
||||
fn append_extension(&mut self, key: &[u8]) {
|
||||
self.buffer.extend(fuse_nibbles_node(key, false));
|
||||
}
|
||||
fn append_substream<H: Hasher>(&mut self, other: Self) {
|
||||
let data = other.out();
|
||||
// println!("[append_substream] START own buffer: {:x?}", self.buffer);
|
||||
// println!("[append_substream] START other buffer: {:x?}", data);
|
||||
match data.len() {
|
||||
0...31 => {
|
||||
// println!("[append_substream] appending data, because data.len() = {}", data.len());
|
||||
data.encode_to(&mut self.buffer)
|
||||
},
|
||||
_ => {
|
||||
// println!("[append_substream] would have hashed, because data.len() = {}", data.len());
|
||||
// data.encode_to(&mut self.buffer)
|
||||
// TODO: re-enable hashing before merging
|
||||
H::hash(&data).as_ref().encode_to(&mut self.buffer)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user