From 9b697b525a77ced0c2d1e5024552ced9ea31e9ce Mon Sep 17 00:00:00 2001 From: aggstam Date: Tue, 10 May 2022 16:58:12 +0300 Subject: [PATCH] src/consensus/util.rs moved to src/util/time.rs, modified corresponding depedencies --- src/blockchain/blockstore.rs | 7 +++++-- src/blockchain/metadatastore.rs | 7 +++++-- src/blockchain/mod.rs | 7 +++++-- src/consensus/block.rs | 7 +++++-- src/consensus/metadata.rs | 7 +++++-- src/consensus/mod.rs | 3 +-- src/consensus/state.rs | 8 +++++--- src/util/mod.rs | 2 ++ src/{consensus/util.rs => util/time.rs} | 0 9 files changed, 33 insertions(+), 15 deletions(-) rename src/{consensus/util.rs => util/time.rs} (100%) diff --git a/src/blockchain/blockstore.rs b/src/blockchain/blockstore.rs index 965e0e656..9ed149262 100644 --- a/src/blockchain/blockstore.rs +++ b/src/blockchain/blockstore.rs @@ -1,6 +1,9 @@ use crate::{ - consensus::{Block, Timestamp}, - util::serial::{deserialize, serialize}, + consensus::Block, + util::{ + serial::{deserialize, serialize}, + time::Timestamp, + }, Error, Result, }; diff --git a/src/blockchain/metadatastore.rs b/src/blockchain/metadatastore.rs index 42d120f40..4cd761eeb 100644 --- a/src/blockchain/metadatastore.rs +++ b/src/blockchain/metadatastore.rs @@ -1,6 +1,9 @@ use crate::{ - consensus::{Block, StreamletMetadata, Timestamp}, - util::serial::{deserialize, serialize}, + consensus::{Block, StreamletMetadata}, + util::{ + serial::{deserialize, serialize}, + time::Timestamp, + }, Error, Result, }; diff --git a/src/blockchain/mod.rs b/src/blockchain/mod.rs index e92f3c616..43890a35f 100644 --- a/src/blockchain/mod.rs +++ b/src/blockchain/mod.rs @@ -3,9 +3,12 @@ use std::io; use log::debug; use crate::{ - consensus::{Block, BlockInfo, Timestamp}, + consensus::{Block, BlockInfo}, impl_vec, - util::serial::{Decodable, Encodable, ReadExt, VarInt, WriteExt}, + util::{ + serial::{Decodable, Encodable, ReadExt, VarInt, WriteExt}, + time::Timestamp, + }, Result, }; diff --git a/src/consensus/block.rs b/src/consensus/block.rs index 20ce53b6b..d65526ccb 100644 --- a/src/consensus/block.rs +++ b/src/consensus/block.rs @@ -2,12 +2,15 @@ use std::io; use log::debug; -use super::{Metadata, StreamletMetadata, Timestamp, BLOCK_VERSION}; +use super::{Metadata, StreamletMetadata, BLOCK_VERSION}; use crate::{ crypto::{address::Address, keypair::PublicKey, schnorr::Signature}, impl_vec, net, tx::Transaction, - util::serial::{serialize, Decodable, Encodable, SerialDecodable, SerialEncodable, VarInt}, + util::{ + serial::{serialize, Decodable, Encodable, SerialDecodable, SerialEncodable, VarInt}, + time::Timestamp, + }, Result, }; diff --git a/src/consensus/metadata.rs b/src/consensus/metadata.rs index bbad7e1a2..17876d40c 100644 --- a/src/consensus/metadata.rs +++ b/src/consensus/metadata.rs @@ -1,5 +1,8 @@ -use super::{Participant, Timestamp, Vote}; -use crate::util::serial::{SerialDecodable, SerialEncodable}; +use super::{Participant, Vote}; +use crate::util::{ + serial::{SerialDecodable, SerialEncodable}, + time::Timestamp, +}; /// This struct represents additional [`Block`] information used by /// the consensus protocol diff --git a/src/consensus/mod.rs b/src/consensus/mod.rs index 6c5016997..ee5ebffaf 100644 --- a/src/consensus/mod.rs +++ b/src/consensus/mod.rs @@ -19,8 +19,7 @@ pub mod state; pub use state::{ValidatorState, ValidatorStatePtr}; /// Utility functions and types -pub mod util; -pub use util::Timestamp; +use crate::util::time::Timestamp; /// P2P net protocols pub mod proto; diff --git a/src/consensus/state.rs b/src/consensus/state.rs index a13fea386..3a123c46d 100644 --- a/src/consensus/state.rs +++ b/src/consensus/state.rs @@ -12,8 +12,7 @@ use log::{debug, error, info, warn}; use rand::rngs::OsRng; use super::{ - Block, BlockInfo, BlockProposal, Metadata, Participant, ProposalChain, StreamletMetadata, - Timestamp, Vote, + Block, BlockInfo, BlockProposal, Metadata, Participant, ProposalChain, StreamletMetadata, Vote, }; use crate::{ blockchain::Blockchain, @@ -28,7 +27,10 @@ use crate::{ Client, MemoryState, State, }, tx::Transaction, - util::serial::{serialize, Encodable, SerialDecodable, SerialEncodable}, + util::{ + serial::{serialize, Encodable, SerialDecodable, SerialEncodable}, + time::Timestamp, + }, Result, }; diff --git a/src/util/mod.rs b/src/util/mod.rs index 8efa09f81..a973ea1c4 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -9,6 +9,7 @@ pub mod net_name; pub mod parse; pub mod path; pub mod serial; +pub mod time; #[cfg(feature = "async-runtime")] pub use async_util::sleep; @@ -16,3 +17,4 @@ pub use async_util::sleep; pub use net_name::NetworkName; pub use parse::{decode_base10, encode_base10}; pub use path::{expand_path, join_config_path, load_keypair_to_str}; +pub use time::Timestamp; diff --git a/src/consensus/util.rs b/src/util/time.rs similarity index 100% rename from src/consensus/util.rs rename to src/util/time.rs