From 6ceea60068362212cd3ad7c5533c4179dda5e6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lo=C3=AFs?= <elois@ifee.fr> Date: Sat, 8 Dec 2018 21:45:58 +0100 Subject: [PATCH] [ref] rust 2018: remove useless extern crate --- bin/durs-server/Cargo.toml | 1 + bin/durs-server/src/main.rs | 13 +- doc/fr/developper-un-module-durs.md | 10 +- lib/core/conf/keys.rs | 2 - lib/core/conf/lib.rs | 7 - lib/core/core/change_conf.rs | 2 +- lib/core/core/cli/dbex.rs | 2 - lib/core/core/cli/keys.rs | 2 - lib/core/core/cli/mod.rs | 2 - lib/core/core/cli/modules.rs | 2 - lib/core/core/cli/reset.rs | 2 - lib/core/core/cli/start.rs | 2 - lib/core/core/lib.rs | 13 -- lib/core/message/lib.rs | 8 - lib/core/module/lib.rs | 7 - lib/core/network/cli/sync.rs | 2 - lib/core/network/lib.rs | 6 - .../blockchain/blockchain-dal/certs.rs | 3 - lib/modules/blockchain/blockchain-dal/lib.rs | 7 - .../blockchain/blockchain-dal/sources.rs | 3 - .../blockchain/blockchain-dal/tools.rs | 2 - lib/modules/blockchain/blockchain/lib.rs | 13 -- lib/modules/blockchain/blockchain/sync.rs | 9 +- .../blockchain/blockchain/ts_parsers.rs | 3 - lib/modules/skeleton/lib.rs | 8 - lib/modules/tui/lib.rs | 11 -- lib/modules/ws2p-v1-legacy/ack_message.rs | 6 +- lib/modules/ws2p-v1-legacy/connect_message.rs | 6 +- lib/modules/ws2p-v1-legacy/lib.rs | 19 -- lib/modules/ws2p-v1-legacy/ok_message.rs | 6 +- lib/modules/ws2p-v1-legacy/parsers/blocks.rs | 2 - .../ws2p-v1-legacy/parsers/excluded.rs | 3 - .../ws2p-v1-legacy/parsers/identities.rs | 2 - .../ws2p-v1-legacy/parsers/memberships.rs | 2 - .../ws2p-v1-legacy/parsers/transactions.rs | 3 - lib/modules/ws2p-v1-legacy/serializer.rs | 2 - lib/modules/ws2p-v1-legacy/ws2p_requests.rs | 5 - lib/modules/ws2p/ws2p-messages/lib.rs | 6 - lib/modules/ws2p/ws2p/constants.rs | 32 ---- lib/modules/ws2p/ws2p/lib.rs | 177 ------------------ .../src/controllers/handler/connect_msg.rs | 2 +- .../ws2p/ws2p/src/controllers/handler/mod.rs | 4 +- .../controllers/incoming_connections/mod.rs | 4 +- lib/modules/ws2p/ws2p/src/controllers/mod.rs | 4 +- .../controllers/outgoing_connections/mod.rs | 4 +- lib/modules/ws2p/ws2p/src/lib.rs | 10 - .../ws2p/ws2p/tests/connection_negociation.rs | 19 +- lib/tools/crypto/src/keys/mod.rs | 2 - lib/tools/crypto/src/lib.rs | 7 - lib/tools/documents/src/lib.rs | 7 - lib/tools/network-documents/src/lib.rs | 8 - .../network-documents/src/network_endpoint.rs | 6 +- .../network-documents/src/network_peer.rs | 4 - lib/tools/wot/lib.rs | 4 - 54 files changed, 34 insertions(+), 464 deletions(-) delete mode 100644 lib/modules/ws2p/ws2p/constants.rs delete mode 100644 lib/modules/ws2p/ws2p/lib.rs diff --git a/bin/durs-server/Cargo.toml b/bin/durs-server/Cargo.toml index c6c59d30..f7c195d6 100644 --- a/bin/durs-server/Cargo.toml +++ b/bin/durs-server/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-a1" authors = ["librelois <elois@duniter.org>","nanocryk <nanocryk@duniter.org>","inso <inso@tuta.io>"] description = "DURS (Dividende Universel RuSt) is a new implementation of Duniter protocol and software in Rust, a safe, concurrent, practical language" license = "AGPL-3.0" +edition = "2018" [dependencies] duniter-core = { path = "../../lib/core/core" } diff --git a/bin/durs-server/src/main.rs b/bin/durs-server/src/main.rs index 175f5ea7..5323ac1a 100644 --- a/bin/durs-server/src/main.rs +++ b/bin/durs-server/src/main.rs @@ -28,17 +28,8 @@ unused_qualifications )] -#[macro_use] -extern crate duniter_core; - -#[cfg(unix)] -extern crate durs_tui; -//extern crate durs_skeleton; -extern crate durs_ws2p_v1_legacy; -//extern crate durs_ws2p; -extern crate structopt; - -pub use duniter_core::{cli::DursOpt, DuRsConf, DuniterCore, UserCommand}; +pub use duniter_core::cli::DursOpt; +pub use duniter_core::*; #[cfg(unix)] pub use durs_tui::TuiModule; //pub use durs_skeleton::SkeletonModule; diff --git a/doc/fr/developper-un-module-durs.md b/doc/fr/developper-un-module-durs.md index d9f76b93..410ecb85 100644 --- a/doc/fr/developper-un-module-durs.md +++ b/doc/fr/developper-un-module-durs.md @@ -286,21 +286,17 @@ Vous pouvez modifier une copie de la ligne du module skeleton pour être sûr de Une fois que vous avez ajouter votre module en dépendance dans le Carego.toml de `durs-server`, il vas falloir utiliser votre module dans le main.rs : -1. Importez la crate principale de votre module, repéréz ou se trouve les autres lignes extern crate puis ajoutez la votre : - - extern crate durs_toto; - -2. Utilisez la structure implémentant le trait DursModule : +1. Utilisez votre structure implémentant le trait DursModule : pub use durs_toto::TotoModule; -3. Ajouter votre module en paramètre de la macro `durs_plug!` : +2. Ajouter votre module en paramètre de la macro `durs_plug!` : durs_plug!([WS2PModule], [TuiModule, .., TotoModule]) Notez que `durs_plug!` prend en paramètre 2 tableaux de modules, le 1er correspond aux modules de type réseau inter-noeuds, tout les autres modules doivent se trouver dans le 2ème tableau. -4. Si votre module doit injecter une sous-commande dans la ligne de commande `durs`, ajoutez le également a la macro `durs_inject_cli!` : +3. Si votre module doit injecter une sous-commande dans la ligne de commande `durs`, ajoutez le également a la macro `durs_inject_cli!` : durs_inject_cli![WS2PModule, .., TotoModule], diff --git a/lib/core/conf/keys.rs b/lib/core/conf/keys.rs index e89a0ab6..1cdc33e6 100644 --- a/lib/core/conf/keys.rs +++ b/lib/core/conf/keys.rs @@ -22,8 +22,6 @@ unused_qualifications )] -extern crate rpassword; - use crate::*; use std::io; diff --git a/lib/core/conf/lib.rs b/lib/core/conf/lib.rs index e549ab48..4df1a506 100644 --- a/lib/core/conf/lib.rs +++ b/lib/core/conf/lib.rs @@ -33,13 +33,6 @@ extern crate serde_derive; #[macro_use] extern crate serde_json; -extern crate dirs; -extern crate dubp_documents; -extern crate duniter_module; -extern crate dup_crypto; -extern crate rand; -extern crate serde; - pub mod keys; use dubp_documents::CurrencyName; diff --git a/lib/core/core/change_conf.rs b/lib/core/core/change_conf.rs index 935b0ed5..e4c5b2bb 100644 --- a/lib/core/core/change_conf.rs +++ b/lib/core/core/change_conf.rs @@ -32,7 +32,7 @@ pub fn change_global_conf<DC: DuniterConf>( } // Write new conf - super::duniter_conf::write_conf_file(profile, &conf).expect("IOError : Fail to update conf "); + ::duniter_conf::write_conf_file(profile, &conf).expect("IOError : Fail to update conf "); println!("Configuration successfully updated."); } diff --git a/lib/core/core/cli/dbex.rs b/lib/core/core/cli/dbex.rs index 180f204d..a7e91a60 100644 --- a/lib/core/core/cli/dbex.rs +++ b/lib/core/core/cli/dbex.rs @@ -15,8 +15,6 @@ //! Durs-core cli : dbex subcommands. -extern crate structopt; - #[derive(StructOpt, Debug, Clone)] #[structopt( name = "dbex", diff --git a/lib/core/core/cli/keys.rs b/lib/core/core/cli/keys.rs index 19c16bb8..14cfa8ac 100644 --- a/lib/core/core/cli/keys.rs +++ b/lib/core/core/cli/keys.rs @@ -15,8 +15,6 @@ //! Durs-core cli : dbex subcommands. -extern crate structopt; - #[derive(StructOpt, Debug, Clone)] #[structopt( name = "keys", diff --git a/lib/core/core/cli/mod.rs b/lib/core/core/cli/mod.rs index 8e69af1c..0e6cdf6e 100644 --- a/lib/core/core/cli/mod.rs +++ b/lib/core/core/cli/mod.rs @@ -15,8 +15,6 @@ //! Define durs-core cli subcommands options. -extern crate structopt; - pub mod dbex; pub mod keys; pub mod modules; diff --git a/lib/core/core/cli/modules.rs b/lib/core/core/cli/modules.rs index 258aad17..97295500 100644 --- a/lib/core/core/cli/modules.rs +++ b/lib/core/core/cli/modules.rs @@ -15,8 +15,6 @@ //! Durs-core cli : modules manager subcommands. -extern crate structopt; - use duniter_module::*; use std::collections::HashSet; diff --git a/lib/core/core/cli/reset.rs b/lib/core/core/cli/reset.rs index a7fc8a34..ba5529ff 100644 --- a/lib/core/core/cli/reset.rs +++ b/lib/core/core/cli/reset.rs @@ -15,8 +15,6 @@ //! Durs-core cli : reset subcommand. -extern crate structopt; - use crate::cli::InvalidInput; use std::str::FromStr; diff --git a/lib/core/core/cli/start.rs b/lib/core/core/cli/start.rs index 4d952859..148a397d 100644 --- a/lib/core/core/cli/start.rs +++ b/lib/core/core/cli/start.rs @@ -15,8 +15,6 @@ //! Durs-core cli : start subcommands. -extern crate structopt; - #[derive(StructOpt, Debug, Copy, Clone)] #[structopt( name = "start", diff --git a/lib/core/core/lib.rs b/lib/core/core/lib.rs index 3c1b7747..5465108f 100644 --- a/lib/core/core/lib.rs +++ b/lib/core/core/lib.rs @@ -33,19 +33,6 @@ extern crate log; #[macro_use] extern crate structopt; -extern crate dirs; -extern crate duniter_conf; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_blockchain; -extern crate durs_message; -extern crate durs_network_documents; -extern crate log_panics; -extern crate serde_json; -extern crate simplelog; -extern crate threadpool; - pub mod change_conf; pub mod cli; pub mod router; diff --git a/lib/core/message/lib.rs b/lib/core/message/lib.rs index 9e53b74d..2f8510ce 100644 --- a/lib/core/message/lib.rs +++ b/lib/core/message/lib.rs @@ -28,14 +28,6 @@ unused_qualifications )] -extern crate dubp_documents; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_network_documents; -extern crate serde; -extern crate serde_json; - use duniter_module::*; use durs_network_documents::network_endpoint::EndpointEnum; diff --git a/lib/core/module/lib.rs b/lib/core/module/lib.rs index 3b687342..75e11894 100644 --- a/lib/core/module/lib.rs +++ b/lib/core/module/lib.rs @@ -32,13 +32,6 @@ #[macro_use] extern crate serde_derive; -extern crate dubp_documents; -extern crate dup_crypto; -extern crate durs_network_documents; -extern crate serde; -extern crate serde_json; -extern crate structopt; - use dubp_documents::CurrencyName; use dup_crypto::keys::{KeyPair, KeyPairEnum}; use durs_network_documents::network_endpoint::EndpointEnum; diff --git a/lib/core/network/cli/sync.rs b/lib/core/network/cli/sync.rs index b7b7c67e..c39158ea 100644 --- a/lib/core/network/cli/sync.rs +++ b/lib/core/network/cli/sync.rs @@ -15,8 +15,6 @@ //! Durs network cli : sync subcommands. -extern crate structopt; - use std::str::FromStr; #[derive(StructOpt, Debug, Clone)] diff --git a/lib/core/network/lib.rs b/lib/core/network/lib.rs index cef3dfb5..44cf7cae 100644 --- a/lib/core/network/lib.rs +++ b/lib/core/network/lib.rs @@ -28,12 +28,6 @@ unused_qualifications )] -extern crate dubp_documents; -extern crate duniter_module; -extern crate dup_crypto; -extern crate durs_network_documents; -extern crate serde; -extern crate serde_json; #[macro_use] extern crate structopt; diff --git a/lib/modules/blockchain/blockchain-dal/certs.rs b/lib/modules/blockchain/blockchain-dal/certs.rs index 9edbf5a4..3515f9f3 100644 --- a/lib/modules/blockchain/blockchain-dal/certs.rs +++ b/lib/modules/blockchain/blockchain-dal/certs.rs @@ -13,9 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -extern crate dubp_documents; -extern crate durs_wot; - use crate::{BinDB, CertsExpirV10Datas, DALError}; use dubp_documents::BlockId; use durs_wot::NodeId; diff --git a/lib/modules/blockchain/blockchain-dal/lib.rs b/lib/modules/blockchain/blockchain-dal/lib.rs index d7c45790..78468397 100644 --- a/lib/modules/blockchain/blockchain-dal/lib.rs +++ b/lib/modules/blockchain/blockchain-dal/lib.rs @@ -32,16 +32,9 @@ #[macro_use] extern crate log; -extern crate serde_json; #[macro_use] extern crate serde_derive; -extern crate dubp_documents; -extern crate dup_crypto; -extern crate durs_wot; -extern crate rustbreak; -extern crate serde; - /// Define balance operations pub mod balance; diff --git a/lib/modules/blockchain/blockchain-dal/sources.rs b/lib/modules/blockchain/blockchain-dal/sources.rs index 3e5b1268..3055e9e8 100644 --- a/lib/modules/blockchain/blockchain-dal/sources.rs +++ b/lib/modules/blockchain/blockchain-dal/sources.rs @@ -13,9 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -extern crate dubp_documents; -extern crate dup_crypto; - use dubp_documents::v10::transaction::*; use dubp_documents::BlockId; use dup_crypto::hashs::Hash; diff --git a/lib/modules/blockchain/blockchain-dal/tools.rs b/lib/modules/blockchain/blockchain-dal/tools.rs index 0800e127..34c55de5 100644 --- a/lib/modules/blockchain/blockchain-dal/tools.rs +++ b/lib/modules/blockchain/blockchain-dal/tools.rs @@ -13,8 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -extern crate durs_wot; - use durs_wot::operations::centrality::{CentralitiesCalculator, UlrikBrandesCentralityCalculator}; use durs_wot::operations::distance::{ DistanceCalculator, RustyDistanceCalculator, WotDistance, WotDistanceParameters, diff --git a/lib/modules/blockchain/blockchain/lib.rs b/lib/modules/blockchain/blockchain/lib.rs index e97b7df4..cad6c573 100644 --- a/lib/modules/blockchain/blockchain/lib.rs +++ b/lib/modules/blockchain/blockchain/lib.rs @@ -32,19 +32,6 @@ #[macro_use] extern crate log; -extern crate dirs; -extern crate dubp_documents; -extern crate duniter_conf; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_blockchain_dal; -extern crate durs_message; -extern crate durs_network_documents; -extern crate durs_wot; -extern crate serde; -extern crate sqlite; - mod apply_valid_block; mod check_and_apply_block; mod dbex; diff --git a/lib/modules/blockchain/blockchain/sync.rs b/lib/modules/blockchain/blockchain/sync.rs index 802eb43a..1ab46712 100644 --- a/lib/modules/blockchain/blockchain/sync.rs +++ b/lib/modules/blockchain/blockchain/sync.rs @@ -13,13 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -extern crate num_cpus; -extern crate pbr; -extern crate sqlite; -extern crate threadpool; - -use self::pbr::ProgressBar; -use self::threadpool::ThreadPool; use crate::ts_parsers::*; use crate::*; use dubp_documents::{BlockHash, BlockId}; @@ -30,12 +23,14 @@ use durs_blockchain_dal::currency_params::CurrencyParameters; use durs_blockchain_dal::writers::requests::*; use durs_blockchain_dal::ForkId; use durs_wot::NodeId; +use pbr::ProgressBar; use std::collections::{HashMap, VecDeque}; use std::fs; use std::ops::Deref; use std::sync::mpsc; use std::thread; use std::time::SystemTime; +use threadpool::ThreadPool; /// Number of sync jobs pub static NB_SYNC_JOBS: &'static usize = &4; diff --git a/lib/modules/blockchain/blockchain/ts_parsers.rs b/lib/modules/blockchain/blockchain/ts_parsers.rs index b5f6166b..1abf79ea 100644 --- a/lib/modules/blockchain/blockchain/ts_parsers.rs +++ b/lib/modules/blockchain/blockchain/ts_parsers.rs @@ -13,9 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -extern crate serde_json; -extern crate sqlite; - use crate::sync::BlockHeader; use dubp_documents::v10::block::{BlockV10Parameters, TxDocOrTxHash}; use dubp_documents::v10::identity::*; diff --git a/lib/modules/skeleton/lib.rs b/lib/modules/skeleton/lib.rs index 8a66e1f0..52679a7e 100644 --- a/lib/modules/skeleton/lib.rs +++ b/lib/modules/skeleton/lib.rs @@ -35,14 +35,6 @@ extern crate serde_derive; #[macro_use] extern crate structopt; -extern crate duniter_conf; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_message; -extern crate serde; -extern crate serde_json; - use duniter_conf::DuRsConf; use duniter_module::*; use duniter_network::events::NetworkEvent; diff --git a/lib/modules/tui/lib.rs b/lib/modules/tui/lib.rs index 80d090e9..57c6e016 100644 --- a/lib/modules/tui/lib.rs +++ b/lib/modules/tui/lib.rs @@ -36,17 +36,6 @@ extern crate serde_derive; #[macro_use] extern crate structopt; -extern crate dubp_documents; -extern crate duniter_conf; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_message; -extern crate durs_network_documents; -extern crate serde; -extern crate serde_json; -extern crate termion; - use duniter_conf::DuRsConf; use duniter_module::*; use duniter_network::events::NetworkEvent; diff --git a/lib/modules/ws2p-v1-legacy/ack_message.rs b/lib/modules/ws2p-v1-legacy/ack_message.rs index 6214d4a2..e1fcdeed 100644 --- a/lib/modules/ws2p-v1-legacy/ack_message.rs +++ b/lib/modules/ws2p-v1-legacy/ack_message.rs @@ -1,10 +1,6 @@ -extern crate dup_crypto; -extern crate serde; -extern crate serde_json; - -use self::serde::ser::{Serialize, SerializeStruct, Serializer}; use super::WS2PMessage; use dup_crypto::keys::*; +use serde::ser::{Serialize, SerializeStruct, Serializer}; #[derive(Debug, Clone)] pub struct WS2PAckMessageV1 { diff --git a/lib/modules/ws2p-v1-legacy/connect_message.rs b/lib/modules/ws2p-v1-legacy/connect_message.rs index e957250c..1f917ade 100644 --- a/lib/modules/ws2p-v1-legacy/connect_message.rs +++ b/lib/modules/ws2p-v1-legacy/connect_message.rs @@ -1,10 +1,6 @@ -extern crate dup_crypto; -extern crate serde; -extern crate serde_json; - -use self::serde::ser::{Serialize, SerializeStruct, Serializer}; use super::WS2PMessage; use dup_crypto::keys::*; +use serde::ser::{Serialize, SerializeStruct, Serializer}; #[derive(Debug, Clone)] pub struct WS2PConnectMessageV1 { diff --git a/lib/modules/ws2p-v1-legacy/lib.rs b/lib/modules/ws2p-v1-legacy/lib.rs index ced1bf9a..3b0c0aa8 100644 --- a/lib/modules/ws2p-v1-legacy/lib.rs +++ b/lib/modules/ws2p-v1-legacy/lib.rs @@ -36,18 +36,6 @@ extern crate serde_json; #[macro_use] extern crate structopt; -extern crate byteorder; -extern crate dubp_documents; -extern crate duniter_conf; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_message; -extern crate durs_network_documents; -extern crate rand; -extern crate sqlite; -extern crate ws; - mod ack_message; mod connect_message; pub mod constants; @@ -943,13 +931,6 @@ impl DursModule<DuRsConf, DursMsg> for WS2PModule { #[cfg(test)] mod tests { - extern crate dubp_documents; - extern crate duniter_conf; - extern crate duniter_module; - extern crate duniter_network; - extern crate dup_crypto; - extern crate durs_message; - use super::parsers::blocks::parse_json_block; use super::*; use dubp_documents::v10::BlockDocument; diff --git a/lib/modules/ws2p-v1-legacy/ok_message.rs b/lib/modules/ws2p-v1-legacy/ok_message.rs index 18986df7..95a63c9d 100644 --- a/lib/modules/ws2p-v1-legacy/ok_message.rs +++ b/lib/modules/ws2p-v1-legacy/ok_message.rs @@ -1,10 +1,6 @@ -extern crate dup_crypto; -extern crate serde; -extern crate serde_json; - -use self::serde::ser::{Serialize, SerializeStruct, Serializer}; use super::WS2PMessage; use dup_crypto::keys::*; +use serde::ser::{Serialize, SerializeStruct, Serializer}; #[derive(Debug, Clone)] pub struct WS2POkMessageV1 { diff --git a/lib/modules/ws2p-v1-legacy/parsers/blocks.rs b/lib/modules/ws2p-v1-legacy/parsers/blocks.rs index d7428a18..dfbe67ac 100644 --- a/lib/modules/ws2p-v1-legacy/parsers/blocks.rs +++ b/lib/modules/ws2p-v1-legacy/parsers/blocks.rs @@ -1,5 +1,3 @@ -extern crate serde_json; - use super::excluded::parse_exclusions_from_json_value; use super::identities::parse_compact_identity; use super::transactions::parse_transaction; diff --git a/lib/modules/ws2p-v1-legacy/parsers/excluded.rs b/lib/modules/ws2p-v1-legacy/parsers/excluded.rs index b2287a16..8e7dd84b 100644 --- a/lib/modules/ws2p-v1-legacy/parsers/excluded.rs +++ b/lib/modules/ws2p-v1-legacy/parsers/excluded.rs @@ -1,6 +1,3 @@ -extern crate serde; -extern crate serde_json; - use dup_crypto::keys::ed25519; use dup_crypto::keys::*; diff --git a/lib/modules/ws2p-v1-legacy/parsers/identities.rs b/lib/modules/ws2p-v1-legacy/parsers/identities.rs index 898a949b..10f3608a 100644 --- a/lib/modules/ws2p-v1-legacy/parsers/identities.rs +++ b/lib/modules/ws2p-v1-legacy/parsers/identities.rs @@ -1,5 +1,3 @@ -extern crate serde_json; - use dubp_documents::v10::identity::*; use dubp_documents::Blockstamp; use dubp_documents::DocumentBuilder; diff --git a/lib/modules/ws2p-v1-legacy/parsers/memberships.rs b/lib/modules/ws2p-v1-legacy/parsers/memberships.rs index 936d84fa..43ceddcb 100644 --- a/lib/modules/ws2p-v1-legacy/parsers/memberships.rs +++ b/lib/modules/ws2p-v1-legacy/parsers/memberships.rs @@ -1,5 +1,3 @@ -extern crate serde_json; - use dubp_documents::v10::membership::*; use dubp_documents::Blockstamp; use dubp_documents::DocumentBuilder; diff --git a/lib/modules/ws2p-v1-legacy/parsers/transactions.rs b/lib/modules/ws2p-v1-legacy/parsers/transactions.rs index 46f2d76f..0a665a38 100644 --- a/lib/modules/ws2p-v1-legacy/parsers/transactions.rs +++ b/lib/modules/ws2p-v1-legacy/parsers/transactions.rs @@ -1,6 +1,3 @@ -extern crate serde; -extern crate serde_json; - use dubp_documents::v10::transaction::{ TransactionDocument, TransactionDocumentBuilder, TransactionInput, TransactionInputUnlocks, TransactionOutput, diff --git a/lib/modules/ws2p-v1-legacy/serializer.rs b/lib/modules/ws2p-v1-legacy/serializer.rs index 52c6c068..5be6ad15 100644 --- a/lib/modules/ws2p-v1-legacy/serializer.rs +++ b/lib/modules/ws2p-v1-legacy/serializer.rs @@ -1,5 +1,3 @@ -extern crate serde_json; - use durs_network_documents::network_head::*; use std::ops::Deref; diff --git a/lib/modules/ws2p-v1-legacy/ws2p_requests.rs b/lib/modules/ws2p-v1-legacy/ws2p_requests.rs index 97a89da5..451e0e0b 100644 --- a/lib/modules/ws2p-v1-legacy/ws2p_requests.rs +++ b/lib/modules/ws2p-v1-legacy/ws2p_requests.rs @@ -1,8 +1,3 @@ -extern crate duniter_network; -extern crate dup_crypto; -extern crate serde; -extern crate serde_json; - use duniter_network::requests::OldNetworkRequest; pub fn network_request_to_json(request: &OldNetworkRequest) -> serde_json::Value { diff --git a/lib/modules/ws2p/ws2p-messages/lib.rs b/lib/modules/ws2p/ws2p-messages/lib.rs index 8248aa04..d853927e 100644 --- a/lib/modules/ws2p/ws2p-messages/lib.rs +++ b/lib/modules/ws2p/ws2p-messages/lib.rs @@ -34,12 +34,6 @@ extern crate pretty_assertions;*/ #[macro_use] extern crate serde_derive; -extern crate bincode; -extern crate byteorder; -extern crate dubp_documents; -extern crate dup_crypto; -extern crate durs_network_documents; - /// WS2Pv2 Messages pub mod v2; diff --git a/lib/modules/ws2p/ws2p/constants.rs b/lib/modules/ws2p/ws2p/constants.rs deleted file mode 100644 index c6cb2866..00000000 --- a/lib/modules/ws2p/ws2p/constants.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2018 The Durs Project Developers. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -pub static WS2P_DEFAULT_OUTCOMING_QUOTA: &'static usize = &10; - -/*pub static WS2P_OUTCOMING_INTERVAL_AT_STARTUP: &'static u64 = &75; -pub static WS2P_OUTCOMING_INTERVAL: &'static u64 = &300;*/ -pub static WS2P_NEGOTIATION_TIMEOUT: &'static u64 = &15_000; -pub static WS2P_EXPIRE_TIMEOUT_IN_SECS: &'static u64 = &120; -pub static WS2P_RECV_SERVICE_FREQ_IN_MS: &'static u64 = &1_000; -pub static WS2P_SPAM_INTERVAL_IN_MILLI_SECS: &'static u64 = &80; -pub static WS2P_SPAM_LIMIT: &'static usize = &6; -pub static WS2P_SPAM_SLEEP_TIME_IN_SEC: &'static u64 = &100; -pub static WS2P_INVALID_MSGS_LIMIT: &'static usize = &5; -/* -pub static WS2P_REQUEST_TIMEOUT: &'static u64 = &30_000; -pub static DURATION_BEFORE_RECORDING_ENDPOINT: &'static u64 = &180; -pub static BLOCKS_REQUEST_INTERVAL: &'static u64 = &60; -pub static PENDING_IDENTITIES_REQUEST_INTERVAL: &'static u64 = &40; -*/ diff --git a/lib/modules/ws2p/ws2p/lib.rs b/lib/modules/ws2p/ws2p/lib.rs deleted file mode 100644 index ad4473df..00000000 --- a/lib/modules/ws2p/ws2p/lib.rs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (C) 2018 The Durs Project Developers. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -//! WebSocketToPeer API for the Duniter project. - -#![cfg_attr(feature = "strict", deny(warnings))] -#![deny( - missing_docs, - missing_debug_implementations, - missing_copy_implementations, - trivial_casts, - unsafe_code, - unstable_features, - unused_import_braces, - unused_qualifications -)] - -#[macro_use] -extern crate log; -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate structopt; - -extern crate bincode; -extern crate dubp_documents; -extern crate duniter_conf; -extern crate durs_message; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_network_documents; -extern crate durs_ws2p_messages; - -mod constants; -mod generate_peer; -pub mod controllers; -pub mod services; - -use constants::*; -use duniter_conf::DuRsConf; -use durs_message::*; -use duniter_module::*; -use duniter_network::*; -use durs_network_documents::network_endpoint::*; -use std::sync::mpsc; - -#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -/// WS2P Configuration -pub struct WS2PConf { - /// Limit of outcoming connections - pub outcoming_quota: usize, - /// Default WS2P endpoints provides by configuration file - pub sync_endpoints: Vec<EndpointEnum>, -} - -impl Default for WS2PConf { - fn default() -> Self { - WS2PConf { - outcoming_quota: *WS2P_DEFAULT_OUTCOMING_QUOTA, - sync_endpoints: vec![ - EndpointV2::parse_from_raw("WS2P g1-monit.librelois.fr 443 ws2p").unwrap(), - EndpointV2::parse_from_raw("WS2P g1.monnaielibreoccitanie.org 443 ws2p").unwrap(), - ], - } - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -/// WS2Pv2 Module -pub struct WS2Pv2Module {} - -impl Default for WS2Pv2Module { - fn default() -> WS2Pv2Module { - WS2Pv2Module {} - } -} - -#[derive(Debug)] -/// WS2PFeaturesParseError -pub enum WS2PFeaturesParseError { - /// UnknowApiFeature - UnknowApiFeature(String), -} - -impl ApiModule<DuRsConf, DursMsg> for WS2Pv2Module { - type ParseErr = WS2PFeaturesParseError; - /// Parse raw api features - fn parse_raw_api_features(str_features: &str) -> Result<ApiFeatures, Self::ParseErr> { - let str_features: Vec<&str> = str_features.split(' ').collect(); - let mut api_features = Vec::with_capacity(0); - for str_feature in str_features { - match str_feature { - "DEF" => api_features[0] += 1u8, - "LOW" => api_features[0] += 2u8, - "ABF" => api_features[0] += 4u8, - _ => { - debug!( - "parse_raw_api_features() = UnknowApiFeature({})", - str_feature - ); - return Err(WS2PFeaturesParseError::UnknowApiFeature(String::from( - str_feature, - ))); - } - } - } - Ok(ApiFeatures(api_features)) - } -} - -impl NetworkModule<DuRsConf, DursMsg> for WS2Pv2Module { - fn sync( - _soft_meta_datas: &SoftwareMetaDatas<DuRsConf>, - _keys: RequiredKeysContent, - _conf: WS2PConf, - _main_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>, - _sync_params: SyncOpt, - ) -> Result<(), ModuleInitError> { - unimplemented!() - } -} - -#[derive(StructOpt, Debug, Copy, Clone)] -#[structopt( - name = "ws2p", - raw(setting = "structopt::clap::AppSettings::ColoredHelp") -)] -/// WS2P subcommand options -pub struct WS2POpt {} - -impl DursModule<DuRsConf, DursMsg> for WS2Pv2Module { - type ModuleConf = WS2PConf; - type ModuleOpt = WS2POpt; - - fn name() -> ModuleStaticName { - ModuleStaticName("ws2p") - } - fn priority() -> ModulePriority { - ModulePriority::Essential() - } - fn ask_required_keys() -> RequiredKeys { - RequiredKeys::NetworkKeyPair() - } - fn have_subcommand() -> bool { - true - } - fn exec_subcommand( - _soft_meta_datas: &SoftwareMetaDatas<DuRsConf>, - _keys: RequiredKeysContent, - _module_conf: Self::ModuleConf, - _subcommand_args: WS2POpt, - ) { - println!("Succesfully exec ws2p subcommand !") - } - fn start( - _soft_meta_datas: &SoftwareMetaDatas<DuRsConf>, - _keys: RequiredKeysContent, - _conf: WS2PConf, - _router_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>, - _load_conf_only: bool, - ) -> Result<(), ModuleInitError> { - unimplemented!() - } -} diff --git a/lib/modules/ws2p/ws2p/src/controllers/handler/connect_msg.rs b/lib/modules/ws2p/ws2p/src/controllers/handler/connect_msg.rs index 737d507b..7ba8205d 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/handler/connect_msg.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/handler/connect_msg.rs @@ -16,10 +16,10 @@ //! Process WS2P CONNECT mesage. use crate::controllers::handler::*; -use crate::controllers::ws::CloseCode; use crate::controllers::*; use durs_network_documents::NodeFullId; use durs_ws2p_messages::v2::connect::WS2Pv2ConnectMsg; +use ws::CloseCode; //use services::Ws2pServiceSender; //use std::sync::mpsc; diff --git a/lib/modules/ws2p/ws2p/src/controllers/handler/mod.rs b/lib/modules/ws2p/ws2p/src/controllers/handler/mod.rs index f4c14767..45e9fc97 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/handler/mod.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/handler/mod.rs @@ -17,12 +17,10 @@ pub mod connect_msg; -extern crate serde_json; - use crate::constants::*; -use crate::controllers::ws::{util::Token, CloseCode, /*Frame,*/ Handler, Handshake, Message}; use crate::controllers::*; use crate::services::*; +use ws::{util::Token, CloseCode, /*Frame,*/ Handler, Handshake, Message}; //use dup_crypto::keys::KeyPairEnum; use dubp_documents::CurrencyName; use durs_network_documents::NodeFullId; diff --git a/lib/modules/ws2p/ws2p/src/controllers/incoming_connections/mod.rs b/lib/modules/ws2p/ws2p/src/controllers/incoming_connections/mod.rs index 4d1271bc..11f80441 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/incoming_connections/mod.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/incoming_connections/mod.rs @@ -18,10 +18,10 @@ use dubp_documents::CurrencyName; //use duniter_module::ModuleReqId; use crate::controllers::handler::Ws2pConnectionHandler; -use crate::controllers::ws::deflate::DeflateBuilder; -use crate::controllers::ws::listen; use crate::controllers::*; use crate::services::*; +use ws::deflate::DeflateBuilder; +use ws::listen; //use duniter_network::*; use durs_ws2p_messages::v2::connect::WS2Pv2ConnectType; use std::sync::mpsc; diff --git a/lib/modules/ws2p/ws2p/src/controllers/mod.rs b/lib/modules/ws2p/ws2p/src/controllers/mod.rs index af186e50..602c7731 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/mod.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/mod.rs @@ -15,12 +15,10 @@ //! WS2P connections controllers. -extern crate ws; - //use constants::*; -use self::ws::Sender; use dubp_documents::Blockstamp; use dup_crypto::hashs::Hash; +use ws::Sender; //use dup_crypto::keys::*; use durs_network_documents::network_peer::PeerCardV11; use durs_network_documents::*; diff --git a/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections/mod.rs b/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections/mod.rs index 4a4f0061..526b2d41 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections/mod.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections/mod.rs @@ -18,12 +18,12 @@ use dubp_documents::CurrencyName; //use duniter_module::ModuleReqId; use crate::controllers::handler::Ws2pConnectionHandler; -use crate::controllers::ws::connect; -use crate::controllers::ws::deflate::DeflateBuilder; use crate::controllers::*; use crate::services::*; use durs_network_documents::network_endpoint::EndpointEnum; use durs_network_documents::NodeFullId; +use ws::connect; +use ws::deflate::DeflateBuilder; //use duniter_network::*; use durs_ws2p_messages::v2::connect::WS2Pv2ConnectType; use std::sync::mpsc; diff --git a/lib/modules/ws2p/ws2p/src/lib.rs b/lib/modules/ws2p/ws2p/src/lib.rs index 42c049b0..03501090 100644 --- a/lib/modules/ws2p/ws2p/src/lib.rs +++ b/lib/modules/ws2p/ws2p/src/lib.rs @@ -34,16 +34,6 @@ extern crate serde_derive; #[macro_use] extern crate structopt; -extern crate bincode; -extern crate dubp_documents; -extern crate duniter_conf; -extern crate duniter_module; -extern crate duniter_network; -extern crate dup_crypto; -extern crate durs_message; -extern crate durs_network_documents; -extern crate durs_ws2p_messages; - mod constants; pub mod controllers; mod generate_peer; diff --git a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs index e48f944b..baa2ee60 100644 --- a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs +++ b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs @@ -1,8 +1,17 @@ -extern crate dubp_documents; -extern crate dup_crypto; -extern crate durs_network_documents; -extern crate durs_ws2p; -extern crate durs_ws2p_messages; +// Copyright (C) 2018 The Durs Project Developers. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. use dubp_documents::CurrencyName; use dup_crypto::keys::KeyPair; diff --git a/lib/tools/crypto/src/keys/mod.rs b/lib/tools/crypto/src/keys/mod.rs index 051dd974..f0b7f5b2 100644 --- a/lib/tools/crypto/src/keys/mod.rs +++ b/lib/tools/crypto/src/keys/mod.rs @@ -46,8 +46,6 @@ //! `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/` //! with `=` as padding character. -extern crate serde; - use base58::ToBase58; use bincode; use std::fmt::Debug; diff --git a/lib/tools/crypto/src/lib.rs b/lib/tools/crypto/src/lib.rs index 91f02991..3a824cc8 100644 --- a/lib/tools/crypto/src/lib.rs +++ b/lib/tools/crypto/src/lib.rs @@ -32,12 +32,5 @@ #[macro_use] extern crate serde_derive; -extern crate base58; -extern crate base64; -extern crate bincode; -extern crate crypto; -extern crate rand; -extern crate serde; - pub mod hashs; pub mod keys; diff --git a/lib/tools/documents/src/lib.rs b/lib/tools/documents/src/lib.rs index 0a7e1a5a..20308e47 100644 --- a/lib/tools/documents/src/lib.rs +++ b/lib/tools/documents/src/lib.rs @@ -26,20 +26,13 @@ unused_import_braces )] -extern crate base58; -extern crate base64; -extern crate byteorder; -extern crate dup_crypto; -extern crate pest; #[macro_use] extern crate pest_derive; #[cfg(test)] #[macro_use] extern crate pretty_assertions; -extern crate serde; #[macro_use] extern crate serde_derive; -extern crate serde_json; pub mod blockstamp; mod currencies_codes; diff --git a/lib/tools/network-documents/src/lib.rs b/lib/tools/network-documents/src/lib.rs index 397cfe23..8ce3f7f4 100644 --- a/lib/tools/network-documents/src/lib.rs +++ b/lib/tools/network-documents/src/lib.rs @@ -26,18 +26,11 @@ unused_import_braces )] -extern crate base58; -extern crate dubp_documents; -extern crate dup_crypto; -extern crate hex; -extern crate pest; #[macro_use] extern crate pest_derive; #[cfg(test)] #[macro_use] extern crate pretty_assertions; -extern crate serde; -extern crate serde_json; #[macro_use] extern crate serde_derive; @@ -161,7 +154,6 @@ impl NodeFullId { #[cfg(test)] mod tests { - pub extern crate bincode; use super::network_endpoint::*; use super::*; diff --git a/lib/tools/network-documents/src/network_endpoint.rs b/lib/tools/network-documents/src/network_endpoint.rs index 4c76f5ba..325d6611 100644 --- a/lib/tools/network-documents/src/network_endpoint.rs +++ b/lib/tools/network-documents/src/network_endpoint.rs @@ -15,10 +15,6 @@ //! Module defining the format of network endpoints and how to handle them. -extern crate dubp_documents; -extern crate dup_crypto; -extern crate serde; - use crate::*; use dup_crypto::hashs::Hash; use dup_crypto::keys::PubKey; @@ -513,7 +509,7 @@ impl EndpointEnum { #[cfg(test)] mod tests { use super::*; - use crate::tests::bincode::{deserialize, serialize}; + use bincode::{deserialize, serialize}; #[test] fn test_network_features() { diff --git a/lib/tools/network-documents/src/network_peer.rs b/lib/tools/network-documents/src/network_peer.rs index 63ee3f38..91bacc53 100644 --- a/lib/tools/network-documents/src/network_peer.rs +++ b/lib/tools/network-documents/src/network_peer.rs @@ -15,10 +15,6 @@ //! Module defining the format of network peer cards and how to handle them. -extern crate dubp_documents; -extern crate dup_crypto; -extern crate serde; - use crate::network_endpoint::*; use crate::*; use base58::ToBase58; diff --git a/lib/tools/wot/lib.rs b/lib/tools/wot/lib.rs index cd53b1f3..707d7108 100644 --- a/lib/tools/wot/lib.rs +++ b/lib/tools/wot/lib.rs @@ -39,10 +39,6 @@ unused_qualifications )] -extern crate bincode; -extern crate byteorder; -extern crate rayon; -extern crate serde; #[macro_use] extern crate serde_derive; -- GitLab