Remove the time dependency where possible (#8100)

This commit is contained in:
Pierre Krieger
2018-03-14 12:29:52 +01:00
committed by Marek Kotewicz
parent 5c47116889
commit 113c35af0a
41 changed files with 169 additions and 179 deletions

View File

@@ -23,7 +23,6 @@ serde_derive = "1.0"
serde_json = "1.0"
slab = "0.3"
smallvec = "0.4"
time = "0.1"
tiny-keccak = "1.3"
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.10" }

View File

@@ -31,7 +31,6 @@ extern crate ring;
extern crate serde;
extern crate slab;
extern crate smallvec;
extern crate time;
extern crate tiny_keccak;
extern crate jsonrpc_core;

View File

@@ -17,7 +17,7 @@
//! Whisper message parsing, handlers, and construction.
use std::fmt;
use std::time::{self, SystemTime, Duration};
use std::time::{self, SystemTime, Duration, Instant};
use ethereum_types::{H256, H512};
use rlp::{self, DecoderError, RlpStream, UntrustedRlp};
@@ -299,9 +299,9 @@ impl Message {
let mut nonce: [u8; 8] = rng.gen();
let mut best_found = try_nonce(&nonce);
let start = ::time::precise_time_ns();
let start = Instant::now();
while ::time::precise_time_ns() <= start + params.work * 1_000_000 {
while start.elapsed() <= Duration::from_millis(params.work) {
let temp_nonce = rng.gen();
let hash = try_nonce(&temp_nonce);