mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
event_graph: guard rpc stuff behind rpc feature
This commit is contained in:
@@ -188,7 +188,7 @@ event-graph = [
|
||||
"darkfi-serial/collections",
|
||||
"darkfi-serial/hash",
|
||||
|
||||
"rpc",
|
||||
"net",
|
||||
]
|
||||
|
||||
p2p-nym = []
|
||||
|
||||
@@ -29,18 +29,22 @@ use smol::{
|
||||
lock::{OnceCell, RwLock},
|
||||
Executor,
|
||||
};
|
||||
use tinyjson::JsonValue::{self};
|
||||
use tracing::{debug, error, info, warn};
|
||||
|
||||
use crate::{
|
||||
event_graph::util::replayer_log,
|
||||
net::P2pPtr,
|
||||
rpc::{
|
||||
system::{msleep, Publisher, PublisherPtr, StoppableTask, StoppableTaskPtr, Subscription},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
#[cfg(feature = "rpc")]
|
||||
use {
|
||||
crate::rpc::{
|
||||
jsonrpc::{JsonResponse, JsonResult},
|
||||
util::json_map,
|
||||
},
|
||||
system::{msleep, Publisher, PublisherPtr, StoppableTask, StoppableTaskPtr, Subscription},
|
||||
Error, Result,
|
||||
tinyjson::JsonValue::{self},
|
||||
};
|
||||
|
||||
/// An event graph event
|
||||
@@ -803,6 +807,7 @@ impl EventGraph {
|
||||
self.deg_publisher.notify(event).await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "rpc")]
|
||||
pub async fn eventgraph_info(&self, id: u16, _params: JsonValue) -> JsonResult {
|
||||
let mut graph = HashMap::new();
|
||||
for iter_elem in self.dag.iter() {
|
||||
|
||||
@@ -17,28 +17,34 @@
|
||||
*/
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::{self, File, OpenOptions},
|
||||
io::Write,
|
||||
path::Path,
|
||||
time::UNIX_EPOCH,
|
||||
};
|
||||
|
||||
use darkfi_serial::{deserialize, deserialize_async, serialize};
|
||||
use sled_overlay::sled;
|
||||
use tinyjson::JsonValue;
|
||||
use tracing::error;
|
||||
|
||||
use crate::{
|
||||
event_graph::{Event, GENESIS_CONTENTS, INITIAL_GENESIS, NULL_ID, N_EVENT_PARENTS},
|
||||
rpc::{
|
||||
jsonrpc::{ErrorCode, JsonError, JsonResponse, JsonResult},
|
||||
util::json_map,
|
||||
},
|
||||
util::{encoding::base64, file::load_file},
|
||||
util::encoding::base64,
|
||||
Result,
|
||||
};
|
||||
|
||||
#[cfg(feature = "rpc")]
|
||||
use {
|
||||
crate::{
|
||||
rpc::{
|
||||
jsonrpc::{ErrorCode, JsonError, JsonResponse, JsonResult},
|
||||
util::json_map,
|
||||
},
|
||||
util::file::load_file,
|
||||
},
|
||||
darkfi_serial::{deserialize, deserialize_async, serialize},
|
||||
sled_overlay::sled,
|
||||
std::collections::HashMap,
|
||||
tinyjson::JsonValue,
|
||||
tracing::error,
|
||||
};
|
||||
|
||||
/// MilliSeconds in a day
|
||||
pub(super) const DAY: i64 = 86_400_000;
|
||||
|
||||
@@ -148,6 +154,7 @@ pub(super) fn replayer_log(datastore: &Path, cmd: String, value: Vec<u8>) -> Res
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "rpc")]
|
||||
pub async fn recreate_from_replayer_log(datastore: &Path) -> JsonResult {
|
||||
let log_path = datastore.join("replayer.log");
|
||||
if !log_path.exists() {
|
||||
|
||||
Reference in New Issue
Block a user