mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
fud: get_info() added
This commit is contained in:
@@ -320,6 +320,15 @@ impl Fud {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RPCAPI:
|
||||
// Retrieves P2P network information.
|
||||
// --> {"jsonrpc": "2.0", "method": "get_info", "params": [], "id": 42}
|
||||
// <-- {"jsonrpc": "2.0", result": {"nodeID": [], "nodeinfo": [], "id": 42}
|
||||
async fn get_info(&self, id: Value, _params: &[Value]) -> JsonResult {
|
||||
let resp = self.dht.read().await.p2p.get_info().await;
|
||||
JsonResponse::new(resp, id).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -335,6 +344,7 @@ impl RequestHandler for Fud {
|
||||
Some("list") => return self.list(req.id, params).await,
|
||||
Some("sync") => return self.sync(req.id, params).await,
|
||||
Some("get") => return self.get(req.id, params).await,
|
||||
Some("get_info") => return self.get_info(req.id, params).await,
|
||||
Some(_) | None => return JsonError::new(MethodNotFound, None, req.id).into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ pub struct Dht {
|
||||
/// Network lookup map, containing nodes that holds each key
|
||||
pub lookup: FxHashMap<blake3::Hash, HashSet<blake3::Hash>>,
|
||||
/// P2P network pointer
|
||||
p2p: P2pPtr,
|
||||
pub p2p: P2pPtr,
|
||||
/// Channel to receive responses from P2P
|
||||
p2p_recv_channel: async_channel::Receiver<KeyResponse>,
|
||||
/// Stop signal channel to terminate background processes
|
||||
|
||||
Reference in New Issue
Block a user