Merge branch 'master' of github.com:gavofyork/ethcore-util

This commit is contained in:
Gav Wood 2015-12-01 02:25:31 +01:00
commit 87e458efed

View File

@ -132,13 +132,13 @@ impl TrieDB {
/// Return the bytes encoding the node represented by `rlp`. It will be unlinked from /// Return the bytes encoding the node represented by `rlp`. It will be unlinked from
/// the trie. /// the trie.
fn take_node(&self, rlp: &Rlp, diff: &mut Diff) -> Bytes { fn take_node<'a, 'rlp_view>(&'a self, rlp: &'rlp_view Rlp<'a>, diff: &mut Diff) -> &'a [u8] where 'a: 'rlp_view {
if rlp.is_list() { if rlp.is_list() {
rlp.raw().to_vec() rlp.raw()
} }
else if rlp.is_data() && rlp.size() == 32 { else if rlp.is_data() && rlp.size() == 32 {
let h = H256::decode(rlp); let h = H256::decode(rlp);
let r = self.db.lookup(&h).expect("Trie root not found!").to_vec(); let r = self.db.lookup(&h).expect("Trie root not found!");
diff.delete_node_sha3(h); diff.delete_node_sha3(h);
r r
} }
@ -260,7 +260,7 @@ impl TrieDB {
// fully-shared prefix for this extension: // fully-shared prefix for this extension:
// skip to the end of this extension and continue the inject there. // skip to the end of this extension and continue the inject there.
let n = self.take_node(&old_rlp.at(1), diff); let n = self.take_node(&old_rlp.at(1), diff);
let downstream_node = self.inject(&n, &partial.mid(cp), value, diff); let downstream_node = self.inject(n, &partial.mid(cp), value, diff);
let mut s = RlpStream::new_list(2); let mut s = RlpStream::new_list(2);
s.append_raw(old_rlp.at(0).raw(), 1); s.append_raw(old_rlp.at(0).raw(), 1);
diff.new_node(downstream_node, &mut s); diff.new_node(downstream_node, &mut s);