diff --git a/bin/durs-server/Cargo.toml b/bin/durs-server/Cargo.toml index c6c59d30247d1be7653460b74bf61786511e53c8..f7c195d61232e5ccbdb4b4b7a1f863d003e23b58 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 175f5ea71af9b5303fb733cde13eebb0f4fc7a40..5323ac1a4e64f07f250ccca005f24627bdc054b1 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 d9f76b930e9948df65c17ff8c3d92c4c7ee56826..410ecb855817dfbcfba1ba928a91aa953582ab0d 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 e89a0ab6d5dba5983f9109badbb279cebd7295cb..1cdc33e645cedb14522799b6ed54ff1a0864b0fd 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 e549ab48f81bb385760bd69e464ba0ec9d7a784b..4df1a506e45aaed2e14a7258b2564cc3e5f6c21c 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 935b0ed52652c4defbd9e4810c1318f729df5c38..e4c5b2bb2188b25c0d47599c682079355c22d71e 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 180f204dbed8bc55e9cc094d7a93dc00b865d7f8..a7e91a6024f11f7f4db867cab77ccc9857b9ae06 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 19c16bb8eb92e527b7739633c52bf2a958e2688b..14cfa8ac849e390e9a20694185b1e7b583fcc66f 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 8e69af1c59ed9b9e7891e32944bb5aebe28b0df5..0e6cdf6e013a1d0008001be321153317cae1255c 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 258aad17657b4a019b6a392eae78b54575faaec1..97295500c396f477b1b03978242e52c9cb91adce 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 a7fc8a3435ad77b734119b5c1f0b2683779efc9a..ba5529ff44a755e652540985b91e1317c06ca067 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 4d9528594aaf0b7972093a23de7ed2672f162626..148a397d57383e41d89e9841784085d738c01604 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 3c1b77479f6fa95849755ddea9ca0a2232628524..5465108f288398f28c31a94a33e2c0716f183063 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 9e53b74d5d691f426cebe7f490f90dd67f21ec74..2f8510ce8b0c7b8b0d96b53e9ccbbae79f050ab3 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 3b68734288d2a6e5ab8bfba2749854a62f736552..75e118947b80f2b5a3827928a45796cf70dcc7f6 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 b7b7c67ed958ee996c534f89d67b1826ecd6bcc8..c39158ea2351d822ac064e02cff39278e23591d3 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 cef3dfb5b8b9ae2de46247668c5a55bd2523ccfa..44cf7cae78c0bcc4a51ae7c868bf14d92afc0aad 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 9edbf5a44fcc3b6e4afd2d291dc44f04595f6018..3515f9f3c55e8e49fda14050c5e25fabc2f069da 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 d7c45790a2fa80e89fb95ed8f7add509fe09e97f..78468397d39f37a493ded69afce1704c9c09ccf7 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 3e5b1268da10ecf21714e4ccf71dab47a5fa15a3..3055e9e87fce6914257a79525f26c4ea871323e1 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 0800e127f7248e6ef3d05f57eaa1fd2133cb44fb..34c55de52d15356be436dc70d3d340b94934876e 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 e97b7df46a89f816f1e8fd7cbeddad6870404984..cad6c5734e1e1f5171e38195880714bcafc01fe8 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 802eb43a0042c6119baa6c5fbb3723bc8c019e0e..1ab46712921e33c4b51bfa0c99b736e153207e3f 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 b5f6166b98e25de11a7f8163c23280cb008e59f7..1abf79eae8f6c51916614a6c84d9790e1c833084 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 8a66e1f0092f0efb5f8dbed1d5fe4f557d2f9eb5..52679a7e17acae6dd7b376d8b8bd213899753343 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 80d090e9e839ba273997074eb17c138664fd9531..57c6e0167f3d5c1b67162c91021dab5155ad3272 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 6214d4a20e5ce2534260958a0f2e8d1d7a1d9c17..e1fcdeed37934ec8ed568e98d33bad0ea166e74e 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 e957250c8206462e59a9523de392144a598bf812..1f917aded01c469b82019f7af394407ecf343d67 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 ced1bf9af805cdc7ce1d4df9df7c545e49579658..3b0c0aa8a39bf8d4ffaae468307028ab192fdca0 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 18986df776dfda94f39f4fca7043fbe7a28c2ecd..95a63c9dbae39afd26c44fb2919ebe1dbe12e67a 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 d7428a182d2835e76e80baa8d7cffd3e590a5e9a..dfbe67ac1621623fb49b7e3880dbd3f1873a8896 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 b2287a1652c30473db61e8664160dc18f344f0e0..8e7dd84b6676ca6dae072635bdabd6a4a6e9cb18 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 898a949befa6364ecc76904e4117f773a7b03716..10f3608a67f94bb365026eb65d94135dde45c649 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 936d84fa07f19acf7c8f517374eb4f3476dee25c..43ceddcb7d0d984cc902d1173abf0fdd7d8af960 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 46f2d76f37057bc3f3d0972c3931d4f95c990549..0a665a38359b5b3a2262c428356b24bfd8074263 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 52c6c0682c61db96dc7a6e9b99af9ef88958ef71..5be6ad15ca34ddb54f42c0cc6a91f5a7a20348be 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 97a89da5310497b45e449bc28657f8b7334c97ee..451e0e0bf97891ccd287dd48f1164d0bc053f81f 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 8248aa0489098f73876e19362b14db7e8c1b6841..d853927e275fa2cf9579e03d4966bdb5c351359e 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 c6cb2866cd3247727e9ad92fa3893320899f1b48..0000000000000000000000000000000000000000 --- 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 ad4473df67bde6f03128982737a24390f5167ac2..0000000000000000000000000000000000000000 --- 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 737d507b58559e27019c76e8b602799e91f91a3f..7ba8205d57ecbed4870f1931bc613b92d20a357e 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 f4c147677a9682cd944f9706c89ab35c035d5c48..45e9fc97497ca44c67a6a72a4d79bd4388e5af2d 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 4d1271bc47b1f13ee6648b79c34c99ceb4653edd..11f80441ebc17667ef11e3eae05426f15356508c 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 af186e508dea218c9dffe0ec7dbf4f5d6176482b..602c7731f721026ed7cf1cb535801e6195ad8fdf 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 4a4f0061e7d27b585904ed31576ec57b3fbd81c8..526b2d4104da8041a3b0bedda7a3d9112529eed0 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 42c049b01b27f941301ee8946ab6310a287acf4a..03501090fa4fde1d6f3991d423f55cea1f5dc7a6 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 e48f944bb9829a41f3e1d3f3c3bed41f45d12200..baa2ee60cbc495fc814bcf65efbb39c419bc462c 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 051dd974d03e870089242685c11851210259eb70..f0b7f5b20234b31b1dbdb0817abf7fca556205c3 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 91f02991e123f52cfcb3f577c6666d172641eeca..3a824cc84bc29fdf0fb28509742f9b1f76a0e170 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 0a7e1a5a16f04343935df5c40abdab74bd0989d5..20308e47935413df5a4c61babe7858a65e30eb96 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 397cfe231678e1a281dec02d23351ae9993b4de3..8ce3f7f4135fd1972c1fc89f227f4c5ed5310f5d 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 4c76f5ba1dfaf9e0125043738d94b074b63fcced..325d661160c38b9e4f97aec808066600b09bd262 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 63ee3f38d508837f0d2f99da1ca1051bf9c30a03..91bacc53fba5e80aeb33311068b21d04294a5a5e 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 cd53b1f36dcb644d843abc1577a0fdb7d89598d3..707d7108a61a64ca7b8c48ea58b85c2036b072d6 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;