This commit is contained in:
debris
2017-08-31 11:35:41 +02:00
parent f0e8abb07b
commit 7849fff41e
43 changed files with 130 additions and 95 deletions

View File

@@ -21,11 +21,12 @@ use std::io::Write;
use std::sync::Arc;
use std::path::PathBuf;
use hash::keccak_buffer;
use fetch::{Fetch, Response, Error as FetchError, Client as FetchClient};
use futures::Future;
use parity_reactor::Remote;
use urlhint::{ContractClient, URLHintContract, URLHint, URLHintResult};
use util::{H256, sha3};
use util::H256;
/// API for fetching by hash.
pub trait HashFetch: Send + Sync + 'static {
@@ -101,7 +102,7 @@ fn validate_hash(path: PathBuf, hash: H256, result: Result<Response, FetchError>
// And validate the hash
let mut file_reader = io::BufReader::new(fs::File::open(&path)?);
let content_hash = sha3(&mut file_reader)?;
let content_hash = keccak_buffer(&mut file_reader)?;
if content_hash != hash {
Err(Error::HashMismatch{ got: content_hash, expected: hash })
} else {

View File

@@ -31,6 +31,7 @@ extern crate native_contracts;
extern crate parity_reactor;
extern crate rand;
extern crate rustc_hex;
extern crate hash;
pub extern crate fetch;

View File

@@ -20,10 +20,11 @@ use std::sync::Arc;
use rustc_hex::ToHex;
use mime::Mime;
use mime_guess;
use hash::keccak;
use futures::{future, BoxFuture, Future};
use native_contracts::{Registry, Urlhint};
use util::{Address, Bytes, Hashable};
use util::{Address, Bytes};
const COMMIT_LEN: usize = 20;
@@ -164,7 +165,7 @@ impl URLHint for URLHintContract {
let urlhint = self.urlhint.clone();
let client = self.client.clone();
self.registrar.get_address(do_call, "githubhint".sha3(), "A".into())
self.registrar.get_address(do_call, keccak("githubhint"), "A".into())
.map(|addr| if addr == Address::default() { None } else { Some(addr) })
.and_then(move |address| {
let mut fixed_id = [0; 32];