diff --git a/lib/modules/blockchain/blockchain/src/lib.rs b/lib/modules/blockchain/blockchain/src/lib.rs index 4674ca8fb2735b78c8fc6b7981c1e8192e394596..812f15d00c12ae3ac418de1237af89a476f6724d 100644 --- a/lib/modules/blockchain/blockchain/src/lib.rs +++ b/lib/modules/blockchain/blockchain/src/lib.rs @@ -45,7 +45,7 @@ mod sync; use std::collections::{HashMap, HashSet}; use std::path::PathBuf; use std::str; -use std::sync::mpsc; +use std::sync::mpsc::{Receiver, RecvTimeoutError, Sender}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use crate::constants::*; @@ -88,7 +88,7 @@ pub static DISTANCE_CALCULATOR: &RustyDistanceCalculator = &RustyDistanceCalcula /// Blockchain Module pub struct BlockchainModule { /// Router sender - pub router_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>, + pub router_sender: Sender<RouterThreadMessage<DursMsg>>, ///Path to the user datas profile pub profile_path: PathBuf, /// Currency @@ -177,7 +177,7 @@ impl BlockchainModule { /// Loading blockchain configuration pub fn load_blockchain_conf( db: Db, - router_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>, + router_sender: Sender<RouterThreadMessage<DursMsg>>, profile_path: PathBuf, _keys: RequiredKeysContent, ) -> BlockchainModule { @@ -251,7 +251,7 @@ impl BlockchainModule { /// Start blockchain module. pub fn start_blockchain( &mut self, - blockchain_receiver: &mpsc::Receiver<DursMsg>, + blockchain_receiver: &Receiver<DursMsg>, sync_opts: Option<SyncOpt>, ) { info!("BlockchainModule::start_blockchain()"); @@ -286,7 +286,7 @@ impl BlockchainModule { } /// Start blockchain main loop - pub fn main_loop(&mut self, blockchain_receiver: &mpsc::Receiver<DursMsg>) { + pub fn main_loop(&mut self, blockchain_receiver: &Receiver<DursMsg>) { // Init main loop datas let mut last_get_stackables_blocks = UNIX_EPOCH; @@ -326,10 +326,10 @@ impl BlockchainModule { } } Err(e) => match e { - mpsc::RecvTimeoutError::Disconnected => { + RecvTimeoutError::Disconnected => { fatal_error!("Disconnected blockchain module !"); } - mpsc::RecvTimeoutError::Timeout => {} + RecvTimeoutError::Timeout => {} }, } // Try to apply local stackable blocks every 20 seconds diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs index 556fa5b53580a4af0d1dd116edb680a3ec6b02b8..f88328b3929a8464afddb373323f3298e69206a9 100644 --- a/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs +++ b/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs @@ -15,12 +15,11 @@ use crate::sync::*; use pbr::ProgressBar; -use std::sync::mpsc; pub fn execute( pool: &ThreadPool, - sender_sync_thread: mpsc::Sender<MessForSyncThread>, - recv: mpsc::Receiver<SyncJobsMess>, + sender_sync_thread: Sender<MessForSyncThread>, + recv: Receiver<SyncJobsMess>, db: Db, target_blockstamp: Blockstamp, mut apply_pb: ProgressBar<std::io::Stdout>, diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs index 5b8b0d2f2116adf0f2670a93318d89197eafee48..6a1a0f439b83df5fd5450e96eae3fd65d0e5e8f5 100644 --- a/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs +++ b/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs @@ -14,13 +14,12 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. use crate::sync::*; -use std::sync::mpsc; pub fn execute( pool: &ThreadPool, profile_path: PathBuf, - sender_sync_thread: mpsc::Sender<MessForSyncThread>, - recv: mpsc::Receiver<SyncJobsMess>, + sender_sync_thread: Sender<MessForSyncThread>, + recv: Receiver<SyncJobsMess>, ) { // Launch tx_worker thread pool.execute(move || { diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs index 4c245a71e33d3081e1e34e06c37f507f87310ba3..2109f199e0fe3652f59690581b79f19bd8acf3a2 100644 --- a/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs +++ b/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs @@ -15,13 +15,12 @@ use crate::sync::*; use std::ops::Deref; -use std::sync::mpsc; pub fn execute( pool: &ThreadPool, profile_path: PathBuf, - sender_sync_thread: mpsc::Sender<MessForSyncThread>, - recv: mpsc::Receiver<SyncJobsMess>, + sender_sync_thread: Sender<MessForSyncThread>, + recv: Receiver<SyncJobsMess>, ) { // Launch wot_worker thread pool.execute(move || { diff --git a/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs b/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs index 8dcbfb644f826899128180c74cf9a86c24e932d4..029afb83994dc50c8dd9abb6ee9059ede2cb9c2f 100644 --- a/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs +++ b/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs @@ -23,7 +23,6 @@ use rayon::prelude::*; use std::collections::HashSet; use std::io::Read; use std::path::{Path, PathBuf}; -use std::sync::mpsc; use threadpool::ThreadPool; /// Number of chunk parsed before sending them to the apply workers @@ -33,7 +32,7 @@ static CHUNKS_STEP: &usize = &16; pub fn json_reader_worker( pool: &ThreadPool, profile_path: PathBuf, - sender_sync_thread: mpsc::Sender<MessForSyncThread>, + sender_sync_thread: Sender<MessForSyncThread>, json_chunks_path: PathBuf, end: Option<u32>, ) {