cleanup of inline rust documentation

pull/19/head
Niko PLP 7 months ago
parent 2b946a3c8d
commit 388bd0e83b
  1. 3
      nextgraph/src/lib.rs
  2. 2
      ng-app/src-tauri/src/lib.rs
  3. 3
      ng-net/src/actor.rs
  4. 4
      ng-net/src/actors/mod.rs
  5. 40
      ng-net/src/broker.rs
  6. 1
      ng-net/src/lib.rs
  7. 2
      ng-net/src/utils.rs
  8. 2
      ng-sdk-js/src/lib.rs
  9. 11
      ng-verifier/src/lib.rs
  10. 5
      ng-verifier/src/site.rs
  11. 9
      ng-verifier/src/types.rs
  12. 2
      ng-verifier/src/user_storage/branch.rs
  13. 2
      ng-verifier/src/user_storage/repo.rs
  14. 28
      ng-verifier/src/verifier.rs
  15. 2
      ngcli/src/main.rs
  16. 2
      ngd/src/main.rs
  17. 1
      ngone/src/main.rs

@ -56,7 +56,8 @@ pub mod net {
}
pub mod verifier {
pub use ng_verifier::*;
pub use ng_verifier::site::*;
pub use ng_verifier::types::*;
}
pub mod wallet {

@ -28,7 +28,7 @@ use ng_wallet::types::*;
use ng_wallet::*;
use nextgraph::local_broker::*;
use nextgraph::verifier::types::*;
use nextgraph::verifier::*;
#[cfg(mobile)]
mod mobile;

@ -32,6 +32,7 @@ impl TryFrom<ProtocolMessage> for () {
}
}
#[doc(hidden)]
#[async_trait::async_trait]
pub trait EActor: Send + Sync + std::fmt::Debug {
async fn respond(
@ -44,7 +45,7 @@ pub trait EActor: Send + Sync + std::fmt::Debug {
}
#[derive(Debug)]
pub struct Actor<
pub(crate) struct Actor<
'a,
A: Into<ProtocolMessage> + std::fmt::Debug,
B: TryFrom<ProtocolMessage, Error = ProtocolError> + std::fmt::Debug + Sync,

@ -1,14 +1,18 @@
//! List of actors, each one for a specific Protocol message
#[doc(hidden)]
pub mod noise;
pub use noise::*;
#[doc(hidden)]
pub mod start;
pub use start::*;
#[doc(hidden)]
pub mod probe;
pub use probe::*;
#[doc(hidden)]
pub mod connecting;
pub use connecting::*;

@ -35,14 +35,14 @@ use crate::utils::spawn_and_log_error;
use crate::utils::{Receiver, ResultSend, Sender};
#[derive(Debug)]
pub enum PeerConnection {
enum PeerConnection {
Core(BindAddress),
Client(ConnectionBase),
NONE,
}
#[derive(Debug)]
pub struct BrokerPeerInfo {
struct BrokerPeerInfo {
#[allow(dead_code)]
last_peer_advert: Option<PeerAdvert>, //FIXME: remove Option
connected: PeerConnection,
@ -50,7 +50,7 @@ pub struct BrokerPeerInfo {
#[derive(Debug)]
#[allow(dead_code)]
pub struct DirectConnection {
struct DirectConnection {
addr: BindAddress,
remote_peer_id: X25519PrivKey,
tp: TransportProtocol,
@ -69,6 +69,7 @@ pub struct ServerConfig {
pub bootstrap: BootstrapContent,
}
#[doc(hidden)]
#[async_trait::async_trait]
pub trait ILocalBroker: Send + Sync + EActor {
async fn deliver(&mut self, event: Event, overlay: OverlayId, user: UserId);
@ -122,28 +123,30 @@ impl Broker {
// }
// }
pub fn get_config(&self) -> Option<&ServerConfig> {
pub(crate) fn get_config(&self) -> Option<&ServerConfig> {
self.config.as_ref()
}
pub fn get_registration_url(&self) -> Option<&String> {
pub(crate) fn get_registration_url(&self) -> Option<&String> {
self.config
.as_ref()
.and_then(|c| c.registration_url.as_ref())
}
pub fn get_bootstrap(&self) -> Result<&BootstrapContent, ProtocolError> {
pub(crate) fn get_bootstrap(&self) -> Result<&BootstrapContent, ProtocolError> {
self.config
.as_ref()
.map(|c| &c.bootstrap)
.ok_or(ProtocolError::BrokerError)
}
#[doc(hidden)]
pub fn set_server_broker(&mut self, broker: impl IServerBroker + 'static) {
//log_debug!("set_server_broker");
self.server_broker = Some(Box::new(broker));
}
#[doc(hidden)]
pub fn set_local_broker(&mut self, broker: Arc<RwLock<dyn ILocalBroker>>) {
//log_debug!("set_local_broker");
self.local_broker = Some(broker);
@ -171,7 +174,7 @@ impl Broker {
(copy_listeners, copy_bind_addresses)
}
pub fn get_server_broker(
pub(crate) fn get_server_broker(
&self,
) -> Result<&Box<dyn IServerBroker + Send + Sync>, ProtocolError> {
//log_debug!("GET STORAGE {:?}", self.server_storage);
@ -180,7 +183,7 @@ impl Broker {
.ok_or(ProtocolError::BrokerError)
}
pub fn get_server_broker_mut(
pub(crate) fn get_server_broker_mut(
&mut self,
) -> Result<&mut Box<dyn IServerBroker + Send + Sync>, ProtocolError> {
//log_debug!("GET STORAGE {:?}", self.server_storage);
@ -199,7 +202,7 @@ impl Broker {
}
#[cfg(not(target_arch = "wasm32"))]
pub fn authorize(
pub(crate) fn authorize(
&self,
bind_addresses: &(BindAddress, BindAddress),
auth: Authorization,
@ -306,7 +309,7 @@ impl Broker {
}
}
pub fn reconnecting(&mut self, peer_id: X25519PrivKey, user: Option<PubKey>) {
fn reconnecting(&mut self, peer_id: X25519PrivKey, user: Option<PubKey>) {
let peerinfo = self.peers.get_mut(&(user, peer_id));
match peerinfo {
Some(info) => match &info.connected {
@ -351,7 +354,8 @@ impl Broker {
}
}
pub fn remove_anonymous(
#[cfg(not(target_arch = "wasm32"))]
fn remove_anonymous(
&mut self,
remote_bind_address: BindAddress,
local_bind_address: BindAddress,
@ -380,7 +384,7 @@ impl Broker {
// }
// }
pub fn new() -> Self {
fn new() -> Self {
let (shutdown_sender, shutdown_receiver) = mpsc::unbounded::<ProtocolError>();
let mut random_buf = [0u8; 4];
getrandom::getrandom(&mut random_buf).unwrap();
@ -496,7 +500,9 @@ impl Broker {
}
}
pub async fn shutdown(&mut self) {
#[allow(dead_code)]
#[cfg(not(target_arch = "wasm32"))]
async fn shutdown(&mut self) {
if self.closing {
return;
}
@ -505,6 +511,7 @@ impl Broker {
let _ = self.shutdown_sender.send(ProtocolError::Closing).await;
}
#[doc(hidden)]
#[cfg(not(target_arch = "wasm32"))]
pub async fn accept(
&mut self,
@ -600,7 +607,7 @@ impl Broker {
}
#[cfg(not(target_arch = "wasm32"))]
pub async fn attach_and_authorize_peer_id(
pub(crate) async fn attach_and_authorize_peer_id(
&mut self,
remote_bind_address: BindAddress,
local_bind_address: BindAddress,
@ -883,7 +890,7 @@ impl Broker {
}
#[cfg(not(target_arch = "wasm32"))]
pub async fn dispatch_event(
pub(crate) async fn dispatch_event(
&mut self,
overlay: &OverlayId,
event: Event,
@ -951,7 +958,7 @@ impl Broker {
.await
}
pub async fn close_anonymous(
async fn close_anonymous(
&mut self,
remote_bind_address: BindAddress,
local_bind_address: BindAddress,
@ -964,6 +971,7 @@ impl Broker {
}
}
#[doc(hidden)]
pub fn print_status(&self) {
self.peers.iter().for_each(|(peer_id, peer_info)| {
log_info!("PEER in BROKER {:?} {:?}", peer_id, peer_info);

@ -15,6 +15,7 @@ pub mod broker;
pub mod server_broker;
#[doc(hidden)]
pub mod connection;
pub mod actor;

@ -29,6 +29,7 @@ use crate::types::*;
#[cfg(target_arch = "wasm32")]
use crate::NG_BOOTSTRAP_LOCAL_PATH;
#[doc(hidden)]
#[cfg(target_arch = "wasm32")]
pub fn spawn_and_log_error<F>(fut: F) -> task::JoinHandle<()>
where
@ -46,6 +47,7 @@ pub type ResultSend<T> = std::result::Result<T, Box<dyn std::error::Error + Send
#[cfg(not(target_arch = "wasm32"))]
pub type ResultSend<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
#[doc(hidden)]
#[cfg(not(target_arch = "wasm32"))]
pub fn spawn_and_log_error<F>(fut: F) -> task::JoinHandle<()>
where

@ -41,7 +41,7 @@ use ng_wallet::types::*;
use ng_wallet::*;
use nextgraph::local_broker::*;
use nextgraph::verifier::types::*;
use nextgraph::verifier::*;
#[wasm_bindgen]
pub async fn get_local_bootstrap(location: String, invite: JsValue) -> JsValue {

@ -1,14 +1,15 @@
pub mod types;
pub mod user_storage;
pub mod site;
#[doc(hidden)]
pub mod verifier;
pub mod site;
mod user_storage;
pub mod commits;
mod commits;
pub mod request_processor;
mod request_processor;
#[cfg(not(target_family = "wasm"))]
pub mod rocksdb_user_storage;
mod rocksdb_user_storage;

@ -19,7 +19,6 @@ use ng_repo::utils::generate_keypair;
use crate::verifier::Verifier;
/// Site V0
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SiteV0 {
pub site_type: SiteType,
@ -37,8 +36,10 @@ pub struct SiteV0 {
// Identity::OrgPrivateStore or Identity::IndividualPrivateStore
pub private: SiteStore,
/// Only for IndividualSite: TODO reorganize those 2 fields
// Only for IndividualSite: TODO reorganize those 2 fields
#[doc(hidden)]
pub cores: Vec<(PubKey, Option<[u8; 32]>)>,
#[doc(hidden)]
pub bootstraps: Vec<PubKey>,
}

@ -22,6 +22,7 @@ use ng_repo::{errors::NgError, types::*};
use ng_net::types::*;
#[doc(hidden)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum SessionPeerLastSeq {
V0(u64),
@ -65,17 +66,18 @@ impl VerifierType {
}
}
}
#[doc(hidden)]
//type LastSeqFn = fn(peer_id: PubKey, qty: u16) -> Result<u64, NgError>;
pub type LastSeqFn = dyn Fn(PubKey, u16) -> Result<u64, NgError> + 'static + Sync + Send;
#[doc(hidden)]
// peer_id: PubKey, seq_num:u64, event_ser: vec<u8>,
pub type OutboxWriteFn =
dyn Fn(PubKey, u64, Vec<u8>) -> Result<(), NgError> + 'static + Sync + Send;
#[doc(hidden)]
// peer_id: PubKey,
pub type OutboxReadFn = dyn Fn(PubKey) -> Result<Vec<Vec<u8>>, NgError> + 'static + Sync + Send;
#[doc(hidden)]
pub struct JsSaveSessionConfig {
pub last_seq_function: Box<LastSeqFn>,
pub outbox_write_function: Box<OutboxWriteFn>,
@ -142,6 +144,7 @@ pub struct VerifierConfig {
pub protected_store_id: Option<RepoId>,
}
#[doc(hidden)]
pub type CancelFn = Box<dyn FnOnce() + Sync + Send>;
//

@ -9,6 +9,8 @@
//! Branch Storage (Object Key/Col/Value Mapping)
#![allow(dead_code)]
use serde_bare::from_slice;
use serde_bare::to_vec;

@ -9,6 +9,8 @@
//! Repo Storage (Object Key/Col/Value Mapping)
#![allow(dead_code)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::sync::{Arc, RwLock};

@ -75,8 +75,8 @@ use crate::user_storage::UserStorage;
// }
pub struct Verifier {
pub config: VerifierConfig,
pub connected_server_id: Option<PubKey>,
pub(crate) config: VerifierConfig,
pub(crate) connected_server_id: Option<PubKey>,
#[allow(dead_code)]
graph_dataset: Option<oxigraph::store::Store>,
pub(crate) user_storage: Option<Arc<Box<dyn UserStorage>>>,
@ -116,7 +116,7 @@ struct EventOutboxStorage {
}
impl Verifier {
pub fn user_privkey(&self) -> &PrivKey {
pub(crate) fn user_privkey(&self) -> &PrivKey {
&self.config.user_priv_key
}
@ -329,7 +329,7 @@ impl Verifier {
))
}
pub fn get_store_or_load(&mut self, store_repo: &StoreRepo) -> Arc<Store> {
fn get_store_or_load(&mut self, store_repo: &StoreRepo) -> Arc<Store> {
let overlay_id = store_repo.overlay_id_for_storage_purpose();
let block_storage = self
.get_arc_block_storage()
@ -349,7 +349,7 @@ impl Verifier {
Arc::clone(store)
}
pub fn complete_site_store(
fn complete_site_store(
&mut self,
store_repo: &StoreRepo,
mut repo: Repo,
@ -386,7 +386,7 @@ impl Verifier {
Ok(repo)
}
pub fn complete_site_store_already_inserted(
fn complete_site_store_already_inserted(
&mut self,
store_repo: StoreRepo,
) -> Result<(), NgError> {
@ -417,7 +417,7 @@ impl Verifier {
Ok(())
}
pub fn get_store(&self, store_repo: &StoreRepo) -> Result<Arc<Store>, VerifierError> {
fn get_store(&self, store_repo: &StoreRepo) -> Result<Arc<Store>, VerifierError> {
let overlay_id = store_repo.overlay_id_for_storage_purpose();
let store = self
.stores
@ -426,7 +426,7 @@ impl Verifier {
Ok(Arc::clone(store))
}
pub fn get_repo_mut(
pub(crate) fn get_repo_mut(
&mut self,
id: &RepoId,
_store_repo: &StoreRepo,
@ -449,7 +449,7 @@ impl Verifier {
repo_ref
}
pub fn add_store(&mut self, store: Arc<Store>) {
fn add_store(&mut self, store: Arc<Store>) {
let overlay_id = store.get_store_repo().overlay_id_for_storage_purpose();
if self.stores.contains_key(&overlay_id) {
return;
@ -1132,7 +1132,7 @@ impl Verifier {
Ok(())
}
pub async fn verify_commit(
pub(crate) async fn verify_commit(
&mut self,
commit: &Commit,
branch_id: &BranchId,
@ -1284,7 +1284,7 @@ impl Verifier {
repo_ref
}
pub async fn bootstrap(&mut self) -> Result<(), NgError> {
async fn bootstrap(&mut self) -> Result<(), NgError> {
if let Err(e) = self.bootstrap_from_remote().await {
log_warn!("bootstrap_from_remote failed with {}", e);
// maybe it failed because the 3P stores are still in the outbox and haven't been sent yet.
@ -1779,7 +1779,7 @@ impl Verifier {
// ret
// }
pub async fn send_outbox(&mut self) -> Result<(), NgError> {
async fn send_outbox(&mut self) -> Result<(), NgError> {
let ret = self.take_events_from_outbox();
// if ret.is_err() {
// log_err!("send_outbox {:}", ret.as_ref().unwrap_err());
@ -2114,7 +2114,7 @@ impl Verifier {
Ok(())
}
pub async fn new_store_default<'a>(
pub(crate) async fn new_store_default<'a>(
&'a mut self,
creator: &UserId,
creator_priv_key: &PrivKey,
@ -2158,7 +2158,7 @@ impl Verifier {
}
/// returns the Repo and the last seq_num of the peer
pub async fn new_repo_default<'a>(
async fn new_repo_default<'a>(
&'a mut self,
creator: &UserId,
creator_priv_key: &PrivKey,

@ -7,6 +7,8 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
#![doc(hidden)]
use core::fmt;
use std::error::Error;
use std::fs::{read_to_string, write};

@ -7,6 +7,8 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
#![doc(hidden)]
pub mod types;
mod cli;

@ -24,6 +24,7 @@ use ng_repo::log::*;
use ng_repo::types::*;
use ng_repo::utils::verify;
#[cfg(not(debug_assertions))]
use ng_net::types::{APP_NG_ONE_URL, NG_ONE_URL};
use ng_wallet::types::*;

Loading…
Cancel
Save