Skip to content
Snippets Groups Projects

WIP: gva first minimal schema with identitydocument

Closed Éloïs requested to merge counter/123-gva-first-minimal-schema-with-identitydocument into dev

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 42 43 #[cfg(not(target_arch = "arm"))]
    43 44 fn main() {
    44 45 durs_core_server!(
    45 durs_inject_cli![WS2PModule /*, SkeletonModule ,DasaModule*/],
    46 durs_plug!([WS2PModule], [TuiModule /*, SkeletonModule ,DasaModule*/])
    46 durs_inject_cli![WS2PModule, GvaModule /*, SkeletonModule ,DasaModule*/],
    47 durs_plug!([WS2PModule], [TuiModule, GvaModule /*, SkeletonModule ,DasaModule*/])
  • 1 [package]
    2 name = "durs-gva"
    3 version = "0.1.0"
    4 authors = ["name <mail@domain.tld>"]
    5 description = "Module template to copy to create a new Durs module."
  • 2 name = "durs-gva"
    3 version = "0.1.0"
    4 authors = ["name <mail@domain.tld>"]
    5 description = "Module template to copy to create a new Durs module."
    6 license = "AGPL-3.0"
    7 edition = "2018"
    8
    9 [lib]
    10 path = "lib.rs"
    11
    12 [dependencies]
    13 duniter-conf = { path = "../../core/conf" }
    14 durs-message = { path = "../../core/message" }
    15 duniter-module = { path = "../../core/module" }
    16 duniter-network = { path = "../../core/network" }
    17 dup-crypto = { path = "../../tools/crypto" }
  • 1 // Copyright (C) 2018 The Duniter Project Developers.
    2 //
    3 // This program is free software: you can redistribute it and/or modify
    4 // it under the terms of the GNU Affero General Public License as
    5 // published by the Free Software Foundation, either version 3 of the
    6 // License, or (at your option) any later version.
    7 //
    8 // This program is distributed in the hope that it will be useful,
    9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11 // GNU Affero General Public License for more details.
    12 //
    13 // You should have received a copy of the GNU Affero General Public License
    14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
    15
    16 //! Module template to copy to create a new Durs module.
  • 3 // This program is free software: you can redistribute it and/or modify
    4 // it under the terms of the GNU Affero General Public License as
    5 // published by the Free Software Foundation, either version 3 of the
    6 // License, or (at your option) any later version.
    7 //
    8 // This program is distributed in the hope that it will be useful,
    9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11 // GNU Affero General Public License for more details.
    12 //
    13 // You should have received a copy of the GNU Affero General Public License
    14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
    15
    16 //! Module template to copy to create a new Durs module.
    17
    18 #![cfg_attr(feature = "strict", deny(warnings))]
  • 39 use duniter_module::*;
    40 use duniter_network::events::NetworkEvent;
    41 use durs_message::events::*;
    42 use durs_message::*;
    43 use std::ops::Deref;
    44 use std::sync::mpsc;
    45 use std::thread;
    46 use std::time::{Duration, SystemTime};
    47
    48 /// Name of your module
    49 pub static MODULE_NAME: &'static str = "gva";
    50
    51 #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
    52 /// Gva Module Configuration
    53 pub struct GvaConf {
    54 test_fake_conf_field: String,
  • 71 pub enum GvaMsg {
    72 /// Message from another module
    73 DursMsg(Box<DursMsg>),
    74 /// Message from others thread of gva module
    75 GvaThreadMsg(GvaThreadMsg),
    76 }
    77
    78 #[derive(StructOpt, Debug, Clone)]
    79 #[structopt(
    80 name = "gva",
    81 raw(setting = "structopt::clap::AppSettings::ColoredHelp")
    82 )]
    83 /// Gva subcommand options
    84 pub struct GvaOpt {
    85 /// Change test conf fake field
    86 pub new_conf_field: String,
  • 102 impl Default for GvaModule {
    103 fn default() -> GvaModule {
    104 GvaModule {}
    105 }
    106 }
    107
    108 impl DursModule<DuRsConf, DursMsg> for GvaModule {
    109 type ModuleConf = GvaConf;
    110 type ModuleOpt = GvaOpt;
    111
    112 fn name() -> ModuleStaticName {
    113 ModuleStaticName(MODULE_NAME)
    114 }
    115 fn priority() -> ModulePriority {
    116 //ModulePriority::Recommended()
    117 ModulePriority::Optional()
  • 105 }
    106 }
    107
    108 impl DursModule<DuRsConf, DursMsg> for GvaModule {
    109 type ModuleConf = GvaConf;
    110 type ModuleOpt = GvaOpt;
    111
    112 fn name() -> ModuleStaticName {
    113 ModuleStaticName(MODULE_NAME)
    114 }
    115 fn priority() -> ModulePriority {
    116 //ModulePriority::Recommended()
    117 ModulePriority::Optional()
    118 }
    119 fn ask_required_keys() -> RequiredKeys {
    120 RequiredKeys::None()
  • 186 let (proxy_sender, proxy_receiver): (mpsc::Sender<DursMsg>, mpsc::Receiver<DursMsg>) =
    187 mpsc::channel();
    188
    189 // Launch a proxy thread that transform DursMsgContent() to SkeleonMsg::DursMsgContent(DursMsgContent())
    190 let router_sender_clone = router_sender.clone();
    191 let gva_sender_clone = gva_sender.clone();
    192 thread::spawn(move || {
    193 // Send gva module registration to router thread
    194 router_sender_clone
    195 .send(RouterThreadMessage::ModuleRegistration(
    196 ModuleStaticName(MODULE_NAME),
    197 proxy_sender, // Messages sent by the router will be received by your proxy thread
    198 vec![ModuleRole::UserInterface], // Roles assigned to your module
    199 vec![ModuleEvent::NewValidBlock], // Events to which your module subscribes
    200 vec![],
    201 vec![],
  • 298 }
    299 GvaMsg::GvaThreadMsg(ref _child_thread_msg) => {
    300 // Do something when receive a message from child thread.
    301 }
    302 },
    303 Err(e) => match e {
    304 mpsc::RecvTimeoutError::Disconnected => {
    305 panic!("Disconnected gva module !");
    306 }
    307 mpsc::RecvTimeoutError::Timeout => {
    308 // If you arrive here it's because your main thread did not receive anything at the end of the timeout.
    309 // This is quite normal and happens regularly when there is little activity, there is nothing particular to do.
    310 }
    311 },
    312 }
    313 // If you want your module's main thread to do things even when it doesn't receive any messages, this is the place where it can do them.
  • Ghost User added 58 commits

    added 58 commits

    Compare with previous version

  • En passant clippy et fmt j'ai vu que le Cargo.toml à la racine comportait "lib/modules/durs-gva" au lieu de "lib/modules/gva". J'ai réglé ce problème. J'en ai donc résolu beaucoup mais je vais pourtant revenir en arrière.

  • @counter-reverse je t'ai fait une review de code il y a 3 semaines avec 12 remarques. Je vois que 11 remarques sur 12 n'ont pas été résolues, du coup je suppose que ce n'était qu'une mise a jours de ta branche :)

    Quand pense tu avoir le temps de traiter mes retours ?

    j'ai vu que le Cargo.toml à la racine comportait "lib/modules/durs-gva" au lieu de "lib/modules/gva". J'ai réglé ce problème. J'en ai donc résolu beaucoup

    C'est toi qui avait rajouté durs-, ce n'est qu'un fix de ton propre code, tu n'a donc rien "résolu", c'est juste normal de corriger ses propres erreurs, c'est 80% du travail d'un développeur ;)

    je vais pourtant revenir en arrière.

    Pourquoi ?

  • Pourquoi ?

    Justement pour répondre aux 11 remarques. J'étais déjà conscient que ce n'était qu'une mise à jour.

  • Ghost User added 79 commits

    added 79 commits

    Compare with previous version

  • J'ai pensé à toutes les remarques par contre j'ai oublié clippy et fmt. J'y vais tout de suite.

    J'ai aussi remarqué une importante mise à jour avec pas mal de refactoring sur le module skeleton. J'y ai fait attention et espère avoir correctement tout pris en compte.

    EDIT: J'ai modifié le commit c943aa50 - [feat] module GVA created mais pas encore fc02d876 - [feat] empty module GVA injected into the server. J'y vais.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading