Skip to content
Snippets Groups Projects
Commit f767597d authored by Éloïs's avatar Éloïs
Browse files

wip elois

parent 5abf4549
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@ macro_rules! durs_cli_main {
#[cfg(not(target_arch = "arm"))]
fn main() {
durs_cli_main!(durs_plug!(
[WS2PModule],
[WS2Pv1Module, WS2PModule],
[TuiModule, GvaModule /*, SkeletonModule ,DasaModule*/]
))
}
......
......@@ -36,14 +36,18 @@ impl Context {
}
}
pub unsafe fn init(db: BcDbRo) {
pub fn init(db: BcDbRo) {
unsafe {
CONTEXT.replace(Context::new(db));
}
}
pub unsafe fn get_context() -> &'static Context {
pub fn get_context() -> &'static Context {
unsafe {
if let Some(ref context) = CONTEXT {
context
} else {
fatal_error!("GVA: no context");
}
}
}
......@@ -13,8 +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/>.
/// Gva Module
//! Gva Module
#![deny(
missing_docs,
......@@ -54,7 +53,7 @@ use std::sync::mpsc;
use std::thread;
use std::time::{Duration, SystemTime};
pub static MODULE_NAME: &str = "gva";
static MODULE_NAME: &str = "gva";
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
/// Gva Module Configuration
......@@ -176,7 +175,7 @@ impl DursModule<DuRsConf, DursMsg> for GvaModule {
Some(new_gva_conf)
}
fn start(
_soft_meta_datas: &SoftwareMetaDatas<DuRsConf>,
soft_meta_datas: &SoftwareMetaDatas<DuRsConf>,
_keys: RequiredKeysContent,
_conf: Self::ModuleConf,
router_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>,
......@@ -247,7 +246,7 @@ impl DursModule<DuRsConf, DursMsg> for GvaModule {
}
});
let smd: SoftwareMetaDatas<DuRsConf> = _soft_meta_datas.clone();
let smd: SoftwareMetaDatas<DuRsConf> = soft_meta_datas.clone();
thread::spawn(move || {
let _ = webserver::start_web_server(&smd);
});
......
......@@ -13,7 +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/>.
use crate::context::Context;
use dubp_block_doc::block::BlockDocumentTrait;
use dubp_common_doc::traits::Document;
......
......@@ -13,7 +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/>.
use crate::context;
use crate::schema::*;
use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer};
......@@ -38,7 +37,7 @@ fn graphql(
st: web::Data<Arc<Schema>>,
data: web::Json<GraphQLRequest>,
) -> impl Future<Item = HttpResponse, Error = Error> {
let context = unsafe { crate::context::get_context() };
let context = crate::context::get_context();
web::block(move || {
let res = data.execute(&st, context);
Ok::<_, serde_json::error::Error>(serde_json::to_string(&res)?)
......@@ -61,9 +60,7 @@ pub fn start_web_server(_soft_meta_datas: &SoftwareMetaDatas<DuRsConf>) -> std::
// Instanciate the context
let db_path = durs_conf::get_blockchain_db_path(_soft_meta_datas.profile_path.clone());
if let Ok(db) = durs_bc_db_reader::open_db_ro(&std::path::Path::new(&db_path)) {
unsafe {
context::init(db);
}
} else {
fatal_error!("GVA: fail to open DB.");
};
......
......@@ -505,6 +505,8 @@ impl DursModule<DuRsConf, DursMsg> for WS2Pv1Module {
// Get start time
let start_time = SystemTime::now();
info!("Start WS2P1 Module.");
// Get key_pair
let key_pair = if let RequiredKeysContent::NetworkKeyPair(key_pair) = keys {
key_pair
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment