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

[ref] improve skeleton module with NetworkEvent example

parent 7e5e68ae
......@@ -37,6 +37,7 @@ 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;
......@@ -44,6 +45,7 @@ extern crate serde_json;
use duniter_conf::DuRsConf;
use duniter_module::*;
use duniter_network::events::NetworkEvent;
use durs_message::events::*;
use durs_message::*;
use std::ops::Deref;
......@@ -270,8 +272,7 @@ impl DuniterModule<DuRsConf, DursMsg> for SkeletonModule {
break;
}
DursMsg::Event {
ref event_content,
..
ref event_content, ..
} => match *event_content {
DursEvent::BlockchainEvent(ref blockchain_event) => {
match *blockchain_event {
......@@ -287,6 +288,17 @@ impl DuniterModule<DuRsConf, DursMsg> for SkeletonModule {
_ => {} // Do nothing for events that don't concern your module.
}
}
DursEvent::NetworkEvent(ref network_event_box) => {
match *network_event_box.deref() {
NetworkEvent::ReceivePeers(ref _peers) => {
// Do something when the node receive peers cards from network
}
NetworkEvent::ReceiveDocuments(ref _bc_documents) => {
// Do something when the node receive blockchain documents from network
}
_ => {} // Do nothing for events that don't concern your module.
}
}
_ => {} // Do nothing for DursEvent variants that don't concern your module.
},
_ => {} // Do nothing for DursMsgContent variants that don't concern your module.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment