Explorar o código

src/consensus/util.rs moved to src/util/time.rs, modified corresponding depedencies

aggstam %!s(int64=4) %!d(string=hai) anos
pai
achega
9b697b525a

+ 5 - 2
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,
 };
 

+ 5 - 2
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,
 };
 

+ 5 - 2
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,
 };
 

+ 5 - 2
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,
 };
 

+ 5 - 2
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

+ 1 - 2
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;

+ 5 - 3
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,
 };
 

+ 2 - 0
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;

+ 0 - 0
src/consensus/util.rs → src/util/time.rs