Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 844aa00

Browse files
committed
Remove time-utils
1 parent 33bfcec commit 844aa00

File tree

13 files changed

+12
-105
lines changed

13 files changed

+12
-105
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Caching, Importing Blocks, and Block Information
318318
journaldb keccak-hasher len-caching-lock macros memory-cache memzero
319319
migration-rocksdb ethcore-network ethcore-network-devp2p panic_hook
320320
patricia-trie-ethereum registrar rlp_compress rlp_derive parity-runtime stats
321-
time-utils triehash-ethereum unexpected parity-version
321+
triehash-ethereum unexpected parity-version
322322
```
323323

324324
</p></details>

ethcore/engines/authority-round/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ parity-bytes = "0.1"
3131
parking_lot = "0.9"
3232
rand = "0.7"
3333
rlp = "0.4.0"
34-
time-utils = { path = "../../../util/time-utils" }
3534
unexpected = { path = "../../../util/unexpected" }
3635
validator-set = { path = "../validator-set" }
3736

ethcore/engines/authority-round/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ use rand::rngs::OsRng;
6161
use rlp::{encode, Decodable, DecoderError, Encodable, RlpStream, Rlp};
6262
use ethereum_types::{H256, H520, Address, U128, U256};
6363
use parking_lot::{Mutex, RwLock};
64-
use time_utils::CheckedSystemTime;
6564
use common_types::{
6665
ancestry_action::AncestryAction,
6766
BlockNumber,
@@ -735,10 +734,10 @@ fn verify_timestamp(step: &Step, header_step: u64) -> Result<(), BlockError> {
735734
// Returning it further won't recover the sync process.
736735
trace!(target: "engine", "verify_timestamp: block too early");
737736

738-
let found = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(oob.found))
737+
let found = UNIX_EPOCH.checked_add(Duration::from_secs(oob.found))
739738
.ok_or(BlockError::TimestampOverflow)?;
740-
let max = oob.max.and_then(|m| CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(m)));
741-
let min = oob.min.and_then(|m| CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(m)));
739+
let max = oob.max.and_then(|m| UNIX_EPOCH.checked_add(Duration::from_secs(m)));
740+
let min = oob.min.and_then(|m| UNIX_EPOCH.checked_add(Duration::from_secs(m)));
742741

743742
let new_oob = OutOfBounds { min, max, found };
744743

ethcore/engines/clique/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ macros = { path = "../../../util/macros" }
2222
rand = "0.7"
2323
parking_lot = "0.9"
2424
rlp = "0.4.0"
25-
time-utils = { path = "../../../util/time-utils" }
2625
unexpected = { path = "../../../util/unexpected" }
2726

2827
[dev-dependencies]

ethcore/engines/clique/src/block_state.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use common_types::{
2828
use ethereum_types::{Address, H64};
2929
use log::{debug, trace};
3030
use rand::Rng;
31-
use time_utils::CheckedSystemTime;
3231
use unexpected::Mismatch;
3332

3433
use crate::{
@@ -273,7 +272,7 @@ impl CliqueBlockState {
273272
// This is a quite bad API because we must mutate both variables even when already `inturn` fails
274273
// That's why we can't return early and must have the `if-else` in the end
275274
pub fn calc_next_timestamp(&mut self, timestamp: u64, period: u64) -> Result<(), Error> {
276-
let inturn = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(timestamp.saturating_add(period)));
275+
let inturn = UNIX_EPOCH.checked_add(Duration::from_secs(timestamp.saturating_add(period)));
277276

278277
self.next_timestamp_inturn = inturn;
279278

ethcore/engines/clique/src/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ use macros::map;
8484
use parking_lot::RwLock;
8585
use rand::Rng;
8686
use unexpected::{Mismatch, OutOfBounds};
87-
use time_utils::CheckedSystemTime;
8887
use common_types::{
8988
BlockNumber,
9089
ids::BlockId,
@@ -571,7 +570,7 @@ impl Engine for Clique {
571570

572571
// Don't waste time checking blocks from the future
573572
{
574-
let limit = CheckedSystemTime::checked_add(SystemTime::now(), Duration::from_secs(self.period))
573+
let limit = SystemTime::now().checked_add(Duration::from_secs(self.period))
575574
.ok_or(BlockError::TimestampOverflow)?;
576575

577576
// This should succeed under the constraints that the system clock works
@@ -581,7 +580,7 @@ impl Engine for Clique {
581580

582581
let hdr = Duration::from_secs(header.timestamp());
583582
if hdr > limit_as_dur {
584-
let found = CheckedSystemTime::checked_add(UNIX_EPOCH, hdr).ok_or(BlockError::TimestampOverflow)?;
583+
let found = UNIX_EPOCH.checked_add(hdr).ok_or(BlockError::TimestampOverflow)?;
585584

586585
Err(BlockError::TemporarilyInvalid(OutOfBounds {
587586
min: None,
@@ -692,8 +691,8 @@ impl Engine for Clique {
692691
// Ensure that the block's timestamp isn't too close to it's parent
693692
let limit = parent.timestamp().saturating_add(self.period);
694693
if limit > header.timestamp() {
695-
let max = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(header.timestamp()));
696-
let found = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(limit))
694+
let max = UNIX_EPOCH.checked_add(Duration::from_secs(header.timestamp()));
695+
let found = UNIX_EPOCH.checked_add(Duration::from_secs(limit))
697696
.ok_or(BlockError::TimestampOverflow)?;
698697

699698
Err(BlockError::InvalidTimestamp(OutOfBounds {

ethcore/private-tx/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ serde_derive = "1.0"
4444
serde_json = "1.0"
4545
spec = { path = "../spec" }
4646
state-db = { path = "../state-db" }
47-
time-utils = { path = "../../util/time-utils" }
4847
tiny-keccak = "1.4"
4948
trace = { path = "../trace" }
5049
transaction-pool = "2.0.1"

ethcore/private-tx/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ extern crate derive_more;
7171
extern crate rlp_derive;
7272
extern crate vm;
7373

74-
#[cfg(not(time_checked_add))]
75-
extern crate time_utils;
76-
7774
#[cfg(test)]
7875
extern crate env_logger;
7976

ethcore/private-tx/src/log.rs

-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ use parking_lot::RwLock;
2626
use serde::ser::{Serializer, SerializeSeq};
2727
use error::Error;
2828

29-
#[cfg(not(time_checked_add))]
30-
use time_utils::CheckedSystemTime;
31-
3229
/// Maximum amount of stored private transaction logs.
3330
const MAX_JOURNAL_LEN: usize = 1000;
3431

@@ -331,9 +328,6 @@ mod tests {
331328
use parking_lot::RwLock;
332329
use super::{TransactionLog, Logging, PrivateTxStatus, LogsSerializer, ValidatorLog};
333330

334-
#[cfg(not(time_checked_add))]
335-
use time_utils::CheckedSystemTime;
336-
337331
struct StringLogSerializer {
338332
string_log: RwLock<String>,
339333
}

ethcore/verification/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ parity-bytes = "0.1.0"
2727
parity-util-mem = "0.3.0"
2828
parking_lot = "0.9"
2929
rlp = "0.4.2"
30-
time-utils = { path = "../../util/time-utils" }
3130
triehash = { package = "triehash-ethereum", version = "0.2", path = "../../util/triehash-ethereum" }
3231
unexpected = { path = "../../util/unexpected" }
3332

ethcore/verification/src/verification.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ use common_types::{
4242
verification::Unverified,
4343
};
4444

45-
use time_utils::CheckedSystemTime;
46-
4745
/// Phase 1 quick block verification. Only does checks that are cheap. Operates on a single block
4846
pub fn verify_block_basic(block: &Unverified, engine: &dyn Engine, check_seal: bool) -> Result<(), Error> {
4947
verify_header_params(&block.header, engine, check_seal)?;
@@ -341,7 +339,7 @@ pub(crate) fn verify_header_time(header: &Header) -> Result<(), Error> {
341339
// this will resist overflow until `year 2037`
342340
let max_time = SystemTime::now() + ACCEPTABLE_DRIFT;
343341
let invalid_threshold = max_time + ACCEPTABLE_DRIFT * 9;
344-
let timestamp = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(header.timestamp()))
342+
let timestamp = UNIX_EPOCH.checked_add(Duration::from_secs(header.timestamp()))
345343
.ok_or(BlockError::TimestampOverflow)?;
346344

347345
if timestamp > invalid_threshold {
@@ -370,9 +368,9 @@ fn verify_parent(header: &Header, parent: &Header, engine: &dyn Engine) -> Resul
370368

371369
if !engine.is_timestamp_valid(header.timestamp(), parent.timestamp()) {
372370
let now = SystemTime::now();
373-
let min = CheckedSystemTime::checked_add(now, Duration::from_secs(parent.timestamp().saturating_add(1)))
371+
let min = now.checked_add(Duration::from_secs(parent.timestamp().saturating_add(1)))
374372
.ok_or(BlockError::TimestampOverflow)?;
375-
let found = CheckedSystemTime::checked_add(now, Duration::from_secs(header.timestamp()))
373+
let found = now.checked_add(Duration::from_secs(header.timestamp()))
376374
.ok_or(BlockError::TimestampOverflow)?;
377375
return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, min: Some(min), found }.into())))
378376
}

util/time-utils/Cargo.toml

-9
This file was deleted.

util/time-utils/src/lib.rs

-66
This file was deleted.

0 commit comments

Comments
 (0)