Commit 6ceea600 authored by Éloïs's avatar Éloïs

[ref] rust 2018: remove useless extern crate

parent c3219f6a
Pipeline #4082 passed with stages
in 9 minutes and 59 seconds
......@@ -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" }
......
......@@ -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;
......
......@@ -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],
......
......@@ -22,8 +22,6 @@
unused_qualifications
)]
extern crate rpassword;
use crate::*;
use std::io;
......
......@@ -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;
......
......@@ -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.");
}
......@@ -15,8 +15,6 @@
//! Durs-core cli : dbex subcommands.
extern crate structopt;
#[derive(StructOpt, Debug, Clone)]
#[structopt(
name = "dbex",
......
......@@ -15,8 +15,6 @@
//! Durs-core cli : dbex subcommands.
extern crate structopt;
#[derive(StructOpt, Debug, Clone)]
#[structopt(
name = "keys",
......
......@@ -15,8 +15,6 @@
//! Define durs-core cli subcommands options.
extern crate structopt;
pub mod dbex;
pub mod keys;
pub mod modules;
......
......@@ -15,8 +15,6 @@
//! Durs-core cli : modules manager subcommands.
extern crate structopt;
use duniter_module::*;
use std::collections::HashSet;
......
......@@ -15,8 +15,6 @@
//! Durs-core cli : reset subcommand.
extern crate structopt;
use crate::cli::InvalidInput;
use std::str::FromStr;
......
......@@ -15,8 +15,6 @@
//! Durs-core cli : start subcommands.
extern crate structopt;
#[derive(StructOpt, Debug, Copy, Clone)]
#[structopt(
name = "start",
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -15,8 +15,6 @@
//! Durs network cli : sync subcommands.
extern crate structopt;
use std::str::FromStr;
#[derive(StructOpt, Debug, Clone)]
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
......@@ -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::*;
......
......@@ -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;
......
......@@ -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;
......
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 {
......
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 {
......
......@@ -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;
......
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 {
......
extern crate serde_json;
use super::excluded::parse_exclusions_from_json_value;
use super::identities::parse_compact_identity;
use super::transactions::parse_transaction;
......
extern crate serde;
extern crate serde_json;
use dup_crypto::keys::ed25519;
use dup_crypto::keys::*;
......
extern crate serde_json;
use dubp_documents::v10::identity::*;
use dubp_documents::Blockstamp;
use dubp_documents::DocumentBuilder;
......
extern crate serde_json;
use dubp_documents::v10::membership::*;
use dubp_documents::Blockstamp;
use dubp_documents::DocumentBuilder;
......
extern crate serde;
extern crate serde_json;
use dubp_documents::v10::transaction::{
TransactionDocument, TransactionDocumentBuilder, TransactionInput, TransactionInputUnlocks,
TransactionOutput,
......
extern crate serde_json;
use durs_network_documents::network_head::*;
use std::ops::Deref;
......
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 {
......
......@@ -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;
......
// 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;
*/
// 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!()
}
}
......@@ -16,10 +16,10 @@
//! Process WS2P CONNECT mesage.
use crate::controllers::handler::*;