pull/19/head
Niko PLP 7 months ago
parent 41e807a4b4
commit e8420e90b0
  1. 5
      nextgraph/Cargo.toml
  2. 5
      nextgraph/src/local_broker.rs
  3. 5
      ng-oxigraph/Cargo.toml
  4. 1
      ng-oxigraph/src/lib.rs
  5. 2
      ng-oxigraph/src/oxigraph/sparql/mod.rs
  6. 4
      ng-oxigraph/src/oxigraph/storage/backend/mod.rs
  7. 3
      ng-oxigraph/src/oxigraph/store.rs
  8. 4
      ng-repo/src/object.rs
  9. 5
      ng-verifier/Cargo.toml
  10. 11
      ng-verifier/src/verifier.rs

@ -32,9 +32,12 @@ ng-wallet = { path = "../ng-wallet", version = "0.1.0-preview.1" }
ng-client-ws = { path = "../ng-client-ws", version = "0.1.0-preview.1" } ng-client-ws = { path = "../ng-client-ws", version = "0.1.0-preview.1" }
ng-verifier = { path = "../ng-verifier", version = "0.1.0-preview.1" } ng-verifier = { path = "../ng-verifier", version = "0.1.0-preview.1" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(all(not(target_arch = "wasm32"),not(doc)))'.dependencies]
ng-storage-rocksdb = { path = "../ng-storage-rocksdb", version = "0.1.0-preview.1" } ng-storage-rocksdb = { path = "../ng-storage-rocksdb", version = "0.1.0-preview.1" }
[package.metadata.docs.rs]
rustc-args = [ "--cfg" , "doc"]
[[example]] [[example]]
name = "in_memory" name = "in_memory"
required-features = [] required-features = []

@ -46,7 +46,7 @@ use ng_wallet::{create_wallet_first_step_v0, create_wallet_second_step_v0, types
use ng_client_ws::remote_ws::ConnectionWebSocket; use ng_client_ws::remote_ws::ConnectionWebSocket;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use ng_client_ws::remote_ws_wasm::ConnectionWebSocket; use ng_client_ws::remote_ws_wasm::ConnectionWebSocket;
#[cfg(not(target_arch = "wasm32"))] #[cfg(all(not(target_family = "wasm"),not(doc)))]
use ng_storage_rocksdb::block_storage::RocksDbBlockStorage; use ng_storage_rocksdb::block_storage::RocksDbBlockStorage;
#[doc(hidden)] #[doc(hidden)]
@ -824,6 +824,7 @@ impl LocalBroker {
(VerifierType::Memory, LocalBrokerConfig::BasePath(_)) => { (VerifierType::Memory, LocalBrokerConfig::BasePath(_)) => {
VerifierConfigType::Memory VerifierConfigType::Memory
} }
#[cfg(all(not(target_family = "wasm"),not(doc)))]
(VerifierType::Save, LocalBrokerConfig::BasePath(base)) => { (VerifierType::Save, LocalBrokerConfig::BasePath(base)) => {
let mut path = base.clone(); let mut path = base.clone();
path.push(format!("user{}", config.user_id().to_hash_string())); path.push(format!("user{}", config.user_id().to_hash_string()));
@ -910,7 +911,7 @@ impl LocalBroker {
Arc::new(std::sync::RwLock::new(HashMapBlockStorage::new())) Arc::new(std::sync::RwLock::new(HashMapBlockStorage::new()))
as Arc<std::sync::RwLock<dyn BlockStorage + Send + Sync + 'static>> as Arc<std::sync::RwLock<dyn BlockStorage + Send + Sync + 'static>>
} else { } else {
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"),not(doc)))]
{ {
let key_material = wallet let key_material = wallet
.client() .client()

@ -44,7 +44,7 @@ quick-xml = ">=0.29, <0.32"
memchr = "2.5" memchr = "2.5"
peg = "0.8" peg = "0.8"
[target.'cfg(not(target_family = "wasm"))'.dependencies] [target.'cfg(all(not(target_family = "wasm"),not(doc)))'.dependencies]
libc = "0.2" libc = "0.2"
ng-rocksdb = { version = "0.21.0", git = "https://git.nextgraph.org/NextGraph/rust-rocksdb.git", branch = "master", features = [ ] } ng-rocksdb = { version = "0.21.0", git = "https://git.nextgraph.org/NextGraph/rust-rocksdb.git", branch = "master", features = [ ] }
@ -56,6 +56,9 @@ js-sys = { version = "0.3.60", optional = true }
codspeed-criterion-compat = "2.3.3" codspeed-criterion-compat = "2.3.3"
zstd = ">=0.12, <0.14" zstd = ">=0.12, <0.14"
[package.metadata.docs.rs]
rustc-args = [ "--cfg" , "doc"]
[lints.rust] [lints.rust]
absolute_paths_not_starting_with_crate = "warn" absolute_paths_not_starting_with_crate = "warn"
elided_lifetimes_in_paths = "warn" elided_lifetimes_in_paths = "warn"

@ -1,4 +1,3 @@
#![doc = include_str!("../README.md")]
#![doc(test(attr(deny(warnings))))] #![doc(test(attr(deny(warnings))))]
#![doc(test(attr(allow(deprecated))))] #![doc(test(attr(allow(deprecated))))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]

@ -1,6 +1,6 @@
//! [SPARQL](https://www.w3.org/TR/sparql11-overview/) implementation. //! [SPARQL](https://www.w3.org/TR/sparql11-overview/) implementation.
//! //!
//! Stores execute SPARQL. See [`Store`](crate::store::Store::query()) for an example. //! Stores execute SPARQL. See [`Store`](crate::oxigraph::store::Store::query()) for an example.
mod algebra; mod algebra;
mod dataset; mod dataset;

@ -1,12 +1,12 @@
//! A storage backend //! A storage backend
//! RocksDB is available, if not in memory //! RocksDB is available, if not in memory
#[cfg(any(target_family = "wasm"))] #[cfg(any(target_family = "wasm", doc))]
pub use fallback::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction}; pub use fallback::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction};
#[cfg(all(not(target_family = "wasm")))] #[cfg(all(not(target_family = "wasm")))]
pub use oxi_rocksdb::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction}; pub use oxi_rocksdb::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction};
#[cfg(any(target_family = "wasm"))] #[cfg(any(target_family = "wasm", doc))]
mod fallback; mod fallback;
#[cfg(all(not(target_family = "wasm")))] #[cfg(all(not(target_family = "wasm")))]
mod oxi_rocksdb; mod oxi_rocksdb;

@ -99,7 +99,7 @@ impl Store {
/// ///
/// Only one read-write [`Store`] can exist at the same time. /// Only one read-write [`Store`] can exist at the same time.
/// If you want to have extra [`Store`] instance opened on a same data /// If you want to have extra [`Store`] instance opened on a same data
/// use [`Store::open_secondary`] or [`Store::open_read_only`]. /// use [`Store::open_read_only`].
#[cfg(all(not(target_family = "wasm")))] #[cfg(all(not(target_family = "wasm")))]
pub fn open(path: impl AsRef<Path>) -> Result<Self, StorageError> { pub fn open(path: impl AsRef<Path>) -> Result<Self, StorageError> {
Ok(Self { Ok(Self {
@ -155,7 +155,6 @@ impl Store {
/// Opens a read-only [`Store`] from disk. /// Opens a read-only [`Store`] from disk.
/// ///
/// Opening as read-only while having an other process writing the database is undefined behavior. /// Opening as read-only while having an other process writing the database is undefined behavior.
/// [`Store::open_secondary`] should be used in this case.
#[cfg(all(not(target_family = "wasm")))] #[cfg(all(not(target_family = "wasm")))]
pub fn open_read_only( pub fn open_read_only(
path: impl AsRef<Path>, path: impl AsRef<Path>,

@ -426,7 +426,7 @@ impl Object {
/// Load an Object from BlockStorage (taking a reference) /// Load an Object from BlockStorage (taking a reference)
/// ///
/// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec<ObjectId>)) of missing BlockIds /// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec of ObjectId)) of missing BlockIds
pub fn load_ref(reference: &ObjectRef, store: &Store) -> Result<Object, ObjectParseError> { pub fn load_ref(reference: &ObjectRef, store: &Store) -> Result<Object, ObjectParseError> {
Self::load(reference.id.clone(), Some(reference.key.clone()), store) Self::load(reference.id.clone(), Some(reference.key.clone()), store)
} }
@ -484,7 +484,7 @@ impl Object {
/// Load an Object from BlockStorage /// Load an Object from BlockStorage
/// ///
/// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec<ObjectId>)) of missing BlockIds /// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec of ObjectId )) of missing BlockIds
pub fn load( pub fn load(
id: ObjectId, id: ObjectId,
key: Option<SymKey>, key: Option<SymKey>,

@ -37,9 +37,12 @@ ng-oxigraph = { path = "../ng-oxigraph", version = "0.4.0-alpha.7-ngpreview" }
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
ng-oxigraph = { path = "../ng-oxigraph", version = "0.4.0-alpha.7-ngpreview", features = ["js"] } ng-oxigraph = { path = "../ng-oxigraph", version = "0.4.0-alpha.7-ngpreview", features = ["js"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(all(not(target_arch = "wasm32"),not(doc)))'.dependencies]
ng-storage-rocksdb = { path = "../ng-storage-rocksdb", version = "0.1.0-preview.1" } ng-storage-rocksdb = { path = "../ng-storage-rocksdb", version = "0.1.0-preview.1" }
getrandom = "0.2.7" getrandom = "0.2.7"
[dev-dependencies] [dev-dependencies]
ng-repo = { path = "../ng-repo", version = "0.1.0-preview.1", features = ["testing"] } ng-repo = { path = "../ng-repo", version = "0.1.0-preview.1", features = ["testing"] }
[package.metadata.docs.rs]
rustc-args = [ "--cfg" , "doc"]

@ -13,9 +13,11 @@ use core::fmt;
use std::cmp::max; use std::cmp::max;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::HashSet; use std::collections::HashSet;
#[cfg(not(target_arch = "wasm32"))] #[cfg(all(not(target_family = "wasm"), not(doc)))]
use std::fs::create_dir_all; use std::fs::create_dir_all;
#[cfg(all(not(target_family = "wasm"), not(doc)))]
use std::fs::{read, File, OpenOptions}; use std::fs::{read, File, OpenOptions};
#[cfg(all(not(target_family = "wasm"), not(doc)))]
use std::io::Write; use std::io::Write;
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
@ -56,7 +58,7 @@ use ng_net::{
}; };
use crate::commits::*; use crate::commits::*;
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), not(doc)))]
use crate::rocksdb_user_storage::RocksDbUserStorage; use crate::rocksdb_user_storage::RocksDbUserStorage;
use crate::types::*; use crate::types::*;
use crate::user_storage::InMemoryUserStorage; use crate::user_storage::InMemoryUserStorage;
@ -712,6 +714,7 @@ impl Verifier {
} }
Ok(res) Ok(res)
} }
#[cfg(all(not(target_family = "wasm"), not(doc)))]
VerifierConfigType::RocksDb(path) => { VerifierConfigType::RocksDb(path) => {
let mut path = path.clone(); let mut path = path.clone();
path.push(format!("outbox{}", self.peer_id.to_hash_string())); path.push(format!("outbox{}", self.peer_id.to_hash_string()));
@ -791,6 +794,7 @@ impl Verifier {
serde_bare::to_vec(&e)?, serde_bare::to_vec(&e)?,
)?; )?;
} }
#[cfg(all(not(target_family = "wasm"), not(doc)))]
VerifierConfigType::RocksDb(path) => { VerifierConfigType::RocksDb(path) => {
let mut path = path.clone(); let mut path = path.clone();
std::fs::create_dir_all(path.clone()).unwrap(); std::fs::create_dir_all(path.clone()).unwrap();
@ -1964,6 +1968,7 @@ impl Verifier {
let res = (js.last_seq_function)(self.peer_id, qty)?; let res = (js.last_seq_function)(self.peer_id, qty)?;
self.max_reserved_seq_num = res + qty as u64; self.max_reserved_seq_num = res + qty as u64;
} }
#[cfg(all(not(target_family = "wasm"), not(doc)))]
VerifierConfigType::RocksDb(path) => { VerifierConfigType::RocksDb(path) => {
let mut path = path.clone(); let mut path = path.clone();
std::fs::create_dir_all(path.clone()).unwrap(); std::fs::create_dir_all(path.clone()).unwrap();
@ -2023,7 +2028,7 @@ impl Verifier {
Some(Box::new(InMemoryUserStorage::new()) as Box<dyn UserStorage>), Some(Box::new(InMemoryUserStorage::new()) as Box<dyn UserStorage>),
Some(block_storage), Some(block_storage),
), ),
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), not(doc)))]
VerifierConfigType::RocksDb(path) => { VerifierConfigType::RocksDb(path) => {
let mut path_oxi = path.clone(); let mut path_oxi = path.clone();
path_oxi.push("graph"); path_oxi.push("graph");

Loading…
Cancel
Save