Commit ff501f44 authored by Éloïs's avatar Éloïs

[ref] migrate to rust edition 2018

parent f32810f8
......@@ -38,14 +38,14 @@ variables:
- rustc --version && cargo --version
.rust_stable_armv7: &rust_stable_armv7
image: registry.duniter.org/docker/rust/armv7-builder:v0.0.4
image: registry.duniter.org/docker/rust/armv7-builder:v0.1
tags:
- redshift-rs-stable
before_script:
- rustc --version && cargo --version
.rust_stable_win64: &rust_stable_win64
image: registry.duniter.org/docker/rust/win64-builder:v0.0.7
image: registry.duniter.org/docker/rust/win64-builder:v0.1.0
tags:
- redshift-rs-stable
before_script:
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "Configuration module for the Duniter project."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -24,8 +24,8 @@
extern crate rpassword;
use crate::*;
use std::io;
use *;
#[derive(Debug, Copy, Clone)]
/// Errors encountered by the wizard
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "Duniter-rs core."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -23,13 +23,13 @@ pub mod modules;
pub mod reset;
pub mod start;
pub use cli::keys::KeysOpt;
pub use dbex::*;
pub use crate::cli::keys::KeysOpt;
pub use crate::dbex::*;
pub use crate::modules::*;
pub use crate::reset::*;
pub use crate::start::*;
pub use duniter_network::cli::sync::SyncOpt;
use log::Level;
pub use modules::*;
pub use reset::*;
pub use start::*;
#[derive(StructOpt, Debug)]
#[structopt(
......
......@@ -17,7 +17,7 @@
extern crate structopt;
use cli::InvalidInput;
use crate::cli::InvalidInput;
use std::str::FromStr;
#[derive(StructOpt, Debug, Copy, Clone)]
......
......@@ -60,8 +60,8 @@ use log::Level;
use simplelog::*;
//use std::error::Error;
//use std::fmt::{Debug, Formatter};
use cli::keys::*;
use cli::*;
use crate::cli::keys::*;
use crate::cli::*;
use std::fs;
use std::fs::{File, OpenOptions};
use std::sync::mpsc;
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "message model for the Durs project."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -13,10 +13,10 @@
// 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 crate::*;
use dubp_documents::v10::block::BlockDocument;
use dubp_documents::*;
use duniter_network::events::NetworkEvent;
use *;
/// The DURS event message.
#[derive(Debug, Clone)]
......
......@@ -48,9 +48,9 @@ pub mod requests;
/// Define requests responses
pub mod responses;
use events::*;
use requests::*;
use responses::*;
use crate::events::*;
use crate::requests::*;
use crate::responses::*;
/// Message exchanged between Durs modules
#[derive(Debug, Clone)]
......
......@@ -13,11 +13,11 @@
// 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 crate::*;
use dubp_documents::BlockId;
use duniter_network::requests::OldNetworkRequest;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::*;
use *;
#[derive(Debug, Clone)]
/// Modules request content
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@duniter.org>"]
description = "Modules model for the Duniter project."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@duniter.org>"]
description = "Network model for the Durs project."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -15,10 +15,10 @@
//! Defined network events.
use documents::*;
use network_head::NetworkHead;
use network_peer::PeerCard;
use NodeFullId;
use crate::documents::*;
use crate::network_head::NetworkHead;
use crate::network_peer::PeerCard;
use crate::NodeFullId;
#[derive(Debug, Clone)]
/// Type containing a network event, each time a network event occurs it's relayed to all modules
......
......@@ -37,7 +37,7 @@ extern crate serde_json;
#[macro_use]
extern crate structopt;
use cli::sync::SyncOpt;
use crate::cli::sync::SyncOpt;
use duniter_module::*;
use durs_network_documents::network_endpoint::ApiFeatures;
use durs_network_documents::network_head::NetworkHead;
......
......@@ -15,10 +15,9 @@
//! Defined network requests.
use documents::*;
use crate::documents::*;
use crate::*;
use dubp_documents::Blockstamp;
use duniter_module::*;
use *;
#[derive(Debug, Copy, Clone)]
/// Type containing a request addressed to the network module
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "Data Access Layer for Durs Blockchain module."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -13,8 +13,8 @@
// 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 sources::*;
use *;
use crate::sources::*;
use crate::*;
/// Get address balance
pub fn get_address_balance(
......
......@@ -14,13 +14,13 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use super::constants::MAX_FORKS;
use crate::*;
use dubp_documents::v10::BlockDocument;
use dubp_documents::Document;
use dubp_documents::{BlockHash, BlockId, Blockstamp, PreviousBlockstamp};
use dup_crypto::keys::*;
use durs_wot::NodeId;
use std::collections::HashMap;
use *;
#[derive(Clone, Debug, Deserialize, Serialize)]
/// A block as it is saved in a database
......
......@@ -16,10 +16,10 @@
extern crate dubp_documents;
extern crate durs_wot;
use crate::{BinDB, CertsExpirV10Datas, DALError};
use dubp_documents::BlockId;
use durs_wot::NodeId;
use std::collections::HashMap;
use {BinDB, CertsExpirV10Datas, DALError};
/// Find certifications that emitted in indicated blocks expiring
pub fn find_expire_certs(
......
......@@ -13,10 +13,10 @@
// 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 constants::*;
use crate::constants::*;
use crate::*;
use dubp_documents::v10::block::BlockV10Parameters;
use dubp_documents::CurrencyName;
use *;
#[derive(Debug, Copy, Clone)]
/// Curerncy parameters
......
......@@ -13,13 +13,13 @@
// 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 currency_params::CurrencyParameters;
use crate::currency_params::CurrencyParameters;
use crate::{BinDB, DALError, IdentitiesV10Datas, MsExpirV10Datas};
use dubp_documents::v10::identity::IdentityDocument;
use dubp_documents::{BlockId, Blockstamp};
use dup_crypto::keys::*;
use durs_wot::NodeId;
use std::collections::HashMap;
use {BinDB, DALError, IdentitiesV10Datas, MsExpirV10Datas};
#[derive(Clone, Debug, Deserialize, Serialize)]
/// Identity state
......
......@@ -91,10 +91,10 @@ use std::fs;
use std::panic::UnwindSafe;
use std::path::PathBuf;
use block::DALBlock;
use identity::DALIdentity;
use sources::{SourceAmount, UTXOContentV10, UTXOIndexV10};
use writers::transaction::DALTxV10;
use crate::block::DALBlock;
use crate::identity::DALIdentity;
use crate::sources::{SourceAmount, UTXOContentV10, UTXOIndexV10};
use crate::writers::transaction::DALTxV10;
#[derive(Debug, Deserialize, Copy, Clone, Ord, PartialEq, PartialOrd, Eq, Hash, Serialize)]
/// Each fork has a unique identifier. The local blockchain (also called local branch) has ForkId equal to zero.
......
......@@ -113,15 +113,14 @@ pub fn compute_distances<T: WebOfTrust + Sync>(
},
)
.expect("Fatal Error: compute_distance return None !");
let mut distance = ((f64::from(distance_datas.success)
let distance = ((f64::from(distance_datas.success)
/ (x_percent * f64::from(distance_datas.sentries)))
* 100.0) as usize;
distances.push(distance);
average_distance += distance;
let mut connectivity =
((f64::from(distance_datas.success - distance_datas.success_at_border)
/ (x_percent * f64::from(distance_datas.sentries)))
* 100.0) as usize;
let connectivity = ((f64::from(distance_datas.success - distance_datas.success_at_border)
/ (x_percent * f64::from(distance_datas.sentries)))
* 100.0) as usize;
connectivities.push(connectivity);
average_connectivity += connectivity;
}
......
......@@ -13,12 +13,12 @@
// 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 block::DALBlock;
use crate::block::DALBlock;
use crate::ForkId;
use crate::{BinDB, DALError, ForksBlocksV10Datas, ForksV10Datas, LocalBlockchainV10Datas};
use dubp_documents::Document;
use dubp_documents::{BlockHash, BlockId, PreviousBlockstamp};
use std::collections::HashMap;
use ForkId;
use {BinDB, DALError, ForksBlocksV10Datas, ForksV10Datas, LocalBlockchainV10Datas};
/// Write DALBlock in databases
pub fn write(
......
......@@ -13,12 +13,12 @@
// 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 currency_params::CurrencyParameters;
use crate::currency_params::CurrencyParameters;
use crate::{BinDB, CertsExpirV10Datas, DALError, IdentitiesV10Datas};
use dubp_documents::v10::certification::CompactCertificationDocument;
use dubp_documents::BlockId;
use dup_crypto::keys::*;
use durs_wot::NodeId;
use {BinDB, CertsExpirV10Datas, DALError, IdentitiesV10Datas};
/// Apply "certification" event in databases
pub fn write_certification(
......
......@@ -13,12 +13,12 @@
// 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 crate::sources::SourceAmount;
use crate::*;
use dubp_documents::v10::transaction::*;
use dubp_documents::BlockId;
use dup_crypto::keys::PubKey;
use sources::SourceAmount;
use std::collections::{HashMap, HashSet};
use *;
/// Apply UD creation in databases
pub fn create_du(
......
......@@ -13,14 +13,14 @@
// 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 currency_params::CurrencyParameters;
use crate::currency_params::CurrencyParameters;
use crate::identity::{DALIdentity, DALIdentityState};
use crate::{BinDB, DALError, IdentitiesV10Datas, MsExpirV10Datas};
use dubp_documents::v10::identity::IdentityDocument;
use dubp_documents::Document;
use dubp_documents::{BlockId, Blockstamp};
use dup_crypto::keys::PubKey;
use durs_wot::NodeId;
use identity::{DALIdentity, DALIdentityState};
use {BinDB, DALError, IdentitiesV10Datas, MsExpirV10Datas};
/// Remove identity from databases
pub fn revert_create_identity(
......
......@@ -13,18 +13,18 @@
// 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 block::DALBlock;
use currency_params::CurrencyParameters;
use crate::block::DALBlock;
use crate::currency_params::CurrencyParameters;
use crate::identity::DALIdentity;
use crate::sources::SourceAmount;
use crate::writers::transaction::DALTxV10;
use crate::*;
use dubp_documents::v10::certification::CompactCertificationDocument;
use dubp_documents::v10::identity::IdentityDocument;
use dubp_documents::Blockstamp;
use dup_crypto::keys::PubKey;
use durs_wot::NodeId;
use identity::DALIdentity;
use sources::SourceAmount;
use std::ops::Deref;
use writers::transaction::DALTxV10;
use *;
#[derive(Debug, Clone)]
/// Contain a pending write request for databases
......
......@@ -15,8 +15,8 @@
use dubp_documents::v10::transaction::*;
use sources::{SourceAmount, SourceIndexV10, UTXOIndexV10, UTXOV10};
use *;
use crate::sources::{SourceAmount, SourceIndexV10, UTXOIndexV10, UTXOV10};
use crate::*;
#[derive(Debug, Copy, Clone)]
/// Transaction error
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "Blockchain module for the Durs project."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -15,14 +15,14 @@
use std::collections::HashMap;
use apply_valid_block::*;
use crate::apply_valid_block::*;
use crate::*;
use dubp_documents::Document;
use dubp_documents::{BlockHash, BlockId, Blockstamp, PreviousBlockstamp};
use duniter_network::documents::NetworkBlock;
use dup_crypto::keys::*;
use durs_blockchain_dal::block::DALBlock;
use durs_blockchain_dal::*;
use *;
#[derive(Debug, Copy, Clone)]
pub enum BlockError {
......
......@@ -13,6 +13,7 @@
// 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 crate::*;
use dubp_documents::v10::transaction::*;
use duniter_module::DuniterConf;
use dup_crypto::keys::*;
......@@ -20,7 +21,6 @@ use durs_blockchain_dal::identity::DALIdentity;
use durs_wot::data::rusty::RustyWebOfTrust;
use durs_wot::operations::distance::{DistanceCalculator, WotDistance, WotDistanceParameters};
use std::time::*;
use *;
#[derive(Debug, Clone)]
/// Query for wot databases explorer
......
......@@ -59,9 +59,9 @@ use std::str;
use std::sync::mpsc;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use apply_valid_block::*;
use check_and_apply_block::*;
pub use dbex::{DBExQuery, DBExTxQuery, DBExWotQuery};
use crate::apply_valid_block::*;
use crate::check_and_apply_block::*;
pub use crate::dbex::{DBExQuery, DBExTxQuery, DBExWotQuery};
use dubp_documents::v10::{BlockDocument, V10Document};
use dubp_documents::*;
use dubp_documents::{DUBPDocument, Document};
......
......@@ -20,6 +20,8 @@ extern crate threadpool;
use self::pbr::ProgressBar;
use self::threadpool::ThreadPool;
use crate::ts_parsers::*;
use crate::*;
use dubp_documents::{BlockHash, BlockId};
use duniter_network::documents::NetworkBlock;
use dup_crypto::hashs::Hash;
......@@ -34,8 +36,6 @@ use std::ops::Deref;
use std::sync::mpsc;
use std::thread;
use std::time::SystemTime;
use ts_parsers::*;
use *;
/// Number of sync jobs
pub static NB_SYNC_JOBS: &'static usize = &4;
......
......@@ -16,6 +16,7 @@
extern crate serde_json;
extern crate sqlite;
use crate::sync::BlockHeader;
use dubp_documents::v10::block::{BlockV10Parameters, TxDocOrTxHash};
use dubp_documents::v10::identity::*;
use dubp_documents::v10::membership::*;
......@@ -28,7 +29,6 @@ use duniter_network::documents::{NetworkBlock, NetworkBlockV10};
use dup_crypto::hashs::Hash;
use dup_crypto::keys::*;
use std::str::FromStr;
use sync::BlockHeader;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
/// MembershipParseError
......
......@@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["name <mail@domain.tld>"]
description = "Module template to copy to create a new Durs module."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "Terminal user interface for Duniter-Rs."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "WebSocketToPeer API for the Durs project."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -13,7 +13,8 @@
// 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 constants::*;
use crate::constants::*;
use crate::*;
use dubp_documents::Blockstamp;
use duniter_network::*;
use dup_crypto::keys::*;
......@@ -24,7 +25,6 @@ use durs_network_documents::network_head::*;
use durs_network_documents::*;
use std::collections::HashSet;
use std::sync::mpsc;
use *;
#[derive(Debug)]
pub struct WS2PModuleDatas {
......@@ -129,7 +129,7 @@ impl WS2PModuleDatas {
let blockstamps_occurences_copy = blockstamps_occurences.clone();
match blockstamps_occurences_copy.get(&head.blockstamp()) {
Some(occurences) => {
let mut occurences_mut = blockstamps_occurences
let occurences_mut = blockstamps_occurences
.get_mut(&head.blockstamp())
.expect("WS2P: Fail to get_mut blockstamps_occurences !");
*occurences_mut += 1;
......
......@@ -13,9 +13,9 @@
// 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 crate::*;
use dubp_documents::Blockstamp;
use durs_network_documents::network_head_v2::*;
use *;
pub fn generate_my_head(
network_keypair: &KeyPairEnum,
......
......@@ -60,10 +60,14 @@ pub mod ws2p_connection;
pub mod ws2p_db;
pub mod ws2p_requests;
use ack_message::WS2PAckMessageV1;
use connect_message::WS2PConnectMessageV1;
use constants::*;
use datas::*;
use crate::ack_message::WS2PAckMessageV1;
use crate::connect_message::WS2PConnectMessageV1;
use crate::constants::*;
use crate::datas::*;
use crate::ok_message::WS2POkMessageV1;
use crate::parsers::blocks::parse_json_block;
use crate::ws2p_connection::*;
use crate::ws2p_requests::network_request_to_json;
use dubp_documents::Blockstamp;
use duniter_conf::DuRsConf;
use duniter_module::*;
......@@ -80,8 +84,6 @@ use durs_message::*;
use durs_network_documents::network_endpoint::*;
use durs_network_documents::network_head::*;
use durs_network_documents::*;
use ok_message::WS2POkMessageV1;
use parsers::blocks::parse_json_block;
use std::collections::HashMap;
use std::ops::Deref;
use std::path::PathBuf;
......@@ -89,8 +91,6 @@ use std::sync::mpsc;
use std::thread;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use ws::Message;
use ws2p_connection::*;
use ws2p_requests::network_request_to_json;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
/// WS2P Configuration
......
use constants::*;
use crate::constants::*;
use crate::parsers::blocks::parse_json_block;
use crate::*;
use duniter_module::ModuleReqId;
use duniter_network::documents::BlockchainDocument;
use dup_crypto::keys::*;
use durs_network_documents::network_endpoint::{EndpointV1, NetworkEndpointApi};
use durs_network_documents::NodeId;
use parsers::blocks::parse_json_block;
use rand::Rng;
use std::sync::mpsc;
use ws::deflate::DeflateBuilder;
#[allow(deprecated)]
use ws::util::{Timeout, Token};
use ws::{connect, CloseCode, Frame, Handler, Handshake, Message, Sender};
use *;
const CONNECT: Token = Token(1);
const EXPIRE: Token = Token(2);
......
......@@ -4,6 +4,7 @@ version = "0.1.0-a0.1"
authors = ["librelois <elois@ifee.fr>"]
description = "Handles WebSocketToPeer API Messages."
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "lib.rs"
......
......@@ -43,10 +43,10 @@ extern crate durs_network_documents;
/// WS2Pv2 Messages
pub mod v2;
use crate::v2::WS2Pv2Message;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::bin_signable::BinSignable;
use dup_crypto::keys::*;
use v2::WS2Pv2Message;
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
/// WS2Pv2Message
......@@ -152,6 +152,8 @@ impl<'de> BinSignable<'de> for WS2PMessage {
#[cfg(test)]
mod tests {
use crate::v2::payload_container::WS2Pv2MessagePayload;
use crate::v2::WS2Pv2Message;
use bincode;
use bincode::{deserialize, serialize};
use dubp_documents::v10::certification::*;
......@@ -163,8 +165,6 @@ mod tests {
use durs_network_documents::*;
use std::net::Ipv4Addr;
use std::str::FromStr;
use v2::payload_container::WS2Pv2MessagePayload;
use v2::WS2Pv2Message;
pub fn keypair1() -> ed25519::KeyPair {
ed25519::KeyPairFromSaltedPasswordGenerator::with_default_parameters().generate(
......
......@@ -153,9 +153,9 @@ pub fn generate_connect_message(
mod tests {
use super::super::*;
use super::*;
use crate::tests::*;
use dubp_documents::Blockstamp;
use dup_crypto::keys::text_signable::TextSignable;
use tests::*;
#[test]
fn test_ws2p_connect_flags() {
......
......@@ -28,13 +28,13 @@ pub mod requests;
/// WS2P v2 SECRET_FLAGS Message
pub mod secret_flags;
use crate::v2::payload_container::*;
use crate::WS2PMessage;
use dubp_documents::CurrencyName;