triehash is separated from util (#6428)

This commit is contained in:
Marek Kotewicz
2017-09-03 09:11:14 +02:00
committed by Gav Wood
parent 7b8af30590
commit b731ccea18
24 changed files with 124 additions and 139 deletions

View File

@@ -709,7 +709,7 @@ impl Body {
pub fn check_response(&self, cache: &Mutex<::cache::Cache>, body: &encoded::Body) -> Result<encoded::Block, Error> {
// check the integrity of the the body against the header
let header = self.0.as_ref()?;
let tx_root = ::util::triehash::ordered_trie_root(body.rlp().at(0).iter().map(|r| r.as_raw().to_vec()));
let tx_root = ::triehash::ordered_trie_root(body.rlp().at(0).iter().map(|r| r.as_raw().to_vec()));
if tx_root != header.transactions_root() {
return Err(Error::WrongTrieRoot(header.transactions_root(), tx_root));
}
@@ -739,7 +739,7 @@ impl BlockReceipts {
/// Check a response with receipts against the stored header.
pub fn check_response(&self, cache: &Mutex<::cache::Cache>, receipts: &[Receipt]) -> Result<Vec<Receipt>, Error> {
let receipts_root = self.0.as_ref()?.receipts_root();
let found_root = ::util::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).into_vec()));
let found_root = ::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).into_vec()));
match receipts_root == found_root {
true => {
@@ -936,7 +936,7 @@ mod tests {
}).collect::<Vec<_>>();
let mut header = Header::new();
let receipts_root = ::util::triehash::ordered_trie_root(
let receipts_root = ::triehash::ordered_trie_root(
receipts.iter().map(|x| ::rlp::encode(x).into_vec())
);