removed some warnings

pull/19/head
Niko PLP 8 months ago
parent f03b6bcc10
commit abf898ac00
  1. 18
      ng-wallet/src/types.rs
  2. 4
      p2p-broker/src/broker_store/account.rs
  3. 24
      p2p-net/src/actor.rs
  4. 21
      p2p-net/src/broker.rs
  5. 57
      p2p-net/src/connection.rs
  6. 9
      p2p-net/src/errors.rs
  7. 4
      p2p-net/src/lib.rs
  8. 14
      p2p-net/src/types.rs
  9. 7
      p2p-net/src/utils.rs
  10. 14
      p2p-repo/src/branch.rs
  11. 14
      p2p-repo/src/commit.rs
  12. 6
      p2p-repo/src/errors.rs
  13. 78
      p2p-repo/src/object.rs
  14. 12
      p2p-repo/src/site.rs
  15. 7
      p2p-repo/src/store.rs
  16. 44
      p2p-repo/src/types.rs

@ -160,11 +160,23 @@ impl ClientV0 {
pub fn id(&self) -> String {
self.priv_key.to_pub().to_string()
}
#[deprecated(note = "**Don't use dummy method**")]
#[deprecated(note = "**Don't use nil method**")]
#[allow(deprecated)]
pub fn nil() -> Self {
ClientV0 {
priv_key: PrivKey::nil(),
storage_master_key: SymKey::nil(),
auto_open: vec![],
}
}
#[cfg(test)]
#[allow(deprecated)]
pub fn dummy() -> Self {
ClientV0 {
priv_key: PrivKey::dummy(),
storage_master_key: SymKey::random(),
priv_key: PrivKey::nil(),
storage_master_key: SymKey::nil(),
auto_open: vec![],
}
}

@ -63,6 +63,8 @@ impl<'a> Account<'a> {
store.put(Self::PREFIX_ACCOUNT, &to_vec(&id)?, None, to_vec(&admin)?)?;
Ok(acc)
}
#[allow(deprecated)]
pub fn get_all_users(
admins: bool,
store: &'a dyn KCVStore,
@ -199,7 +201,7 @@ impl<'a> Account<'a> {
// let mut id_and_client = to_vec(&self.id)?;
// let client_key = (client.clone(), hash);
// let mut client_key_ser = to_vec(&client_key)?;
#[allow(deprecated)]
let client_key = (ClientId::nil(), 0u64);
let mut client_key_ser = to_vec(&client_key)?;
let size = client_key_ser.len() + id.len();

@ -10,11 +10,9 @@
*/
use async_std::stream::StreamExt;
use async_std::sync::{Mutex, MutexGuard};
use async_std::sync::Mutex;
use futures::{channel::mpsc, SinkExt};
use serde::de::DeserializeOwned;
use std::any::{Any, TypeId};
use std::convert::From;
use std::any::TypeId;
use std::sync::Arc;
use crate::utils::{spawn_and_log_error, Receiver, ResultSend, Sender};
@ -23,7 +21,7 @@ use std::marker::PhantomData;
impl TryFrom<ProtocolMessage> for () {
type Error = ProtocolError;
fn try_from(msg: ProtocolMessage) -> Result<Self, Self::Error> {
fn try_from(_msg: ProtocolMessage) -> Result<Self, Self::Error> {
Ok(())
}
}
@ -58,7 +56,7 @@ pub enum SoS<B> {
impl<B> SoS<B> {
pub fn is_single(&self) -> bool {
if let Self::Single(b) = self {
if let Self::Single(_b) = self {
true
} else {
false
@ -70,7 +68,7 @@ impl<B> SoS<B> {
pub fn unwrap_single(self) -> B {
match self {
Self::Single(s) => s,
Self::Stream(s) => {
Self::Stream(_s) => {
panic!("called `unwrap_single()` on a `Stream` value")
}
}
@ -78,7 +76,7 @@ impl<B> SoS<B> {
pub fn unwrap_stream(self) -> Receiver<B> {
match self {
Self::Stream(s) => s,
Self::Single(s) => {
Self::Single(_s) => {
panic!("called `unwrap_stream()` on a `Single` value")
}
}
@ -91,7 +89,7 @@ impl<
> Actor<'_, A, B>
{
pub fn new(id: i64, initiator: bool) -> Self {
let (mut receiver_tx, receiver) = mpsc::unbounded::<ConnectionCommand>();
let (receiver_tx, receiver) = mpsc::unbounded::<ConnectionCommand>();
Self {
id,
receiver: Some(receiver),
@ -125,11 +123,11 @@ impl<
&& TypeId::of::<B>() != TypeId::of::<()>()
{
let (mut b_sender, b_receiver) = mpsc::unbounded::<B>();
let response = msg.try_into().map_err(|e| ProtocolError::ActorError)?;
let response = msg.try_into().map_err(|_e| ProtocolError::ActorError)?;
b_sender
.send(response)
.await
.map_err(|err| ProtocolError::IoError)?;
.map_err(|_err| ProtocolError::IoError)?;
async fn pump_stream<C: TryFrom<ProtocolMessage, Error = ProtocolError>>(
mut actor_receiver: Receiver<ConnectionCommand>,
mut sos_sender: Sender<C>,
@ -193,15 +191,15 @@ impl<
}
}
#[cfg(test)]
mod test {
use crate::actor::*;
use crate::actors::*;
use crate::types::*;
#[async_std::test]
pub async fn test_actor() {
let mut a = Actor::<Noise, Noise>::new(1, true);
let _a = Actor::<Noise, Noise>::new(1, true);
// a.handle(ProtocolMessage::Start(StartProtocol::Client(
// ClientHello::Noise3(Noise::V0(NoiseV0 { data: vec![] })),
// )))

@ -9,7 +9,6 @@
* according to those terms.
*/
use crate::actor::*;
use crate::connection::*;
use crate::errors::*;
use crate::server_storage::ServerStorage;
@ -21,8 +20,6 @@ use async_std::sync::{Arc, RwLock};
use either::Either;
use futures::channel::mpsc;
use futures::SinkExt;
use noise_protocol::U8Array;
use noise_rust_crypto::sensitive::Sensitive;
use once_cell::sync::Lazy;
use p2p_repo::log::*;
use p2p_repo::object::Object;
@ -31,12 +28,6 @@ use p2p_repo::store::HashMapRepoStore;
use p2p_repo::types::*;
use p2p_repo::utils::generate_keypair;
use std::collections::HashMap;
use std::net::IpAddr;
use std::ops::Deref;
use std::io::BufReader;
use std::io::Read;
use std::path::PathBuf;
#[derive(Debug)]
pub enum PeerConnection {
@ -332,7 +323,7 @@ impl<'a> Broker<'a> {
}
pub async fn doc_sync_branch(&mut self, anuri: String) -> (Receiver<Commit>, Sender<Commit>) {
let (mut tx, rx) = mpsc::unbounded::<Commit>();
let (tx, rx) = mpsc::unbounded::<Commit>();
let obj_ref = ObjectRef {
id: ObjectId::Blake3Digest32([
@ -637,7 +628,7 @@ impl<'a> Broker<'a> {
log_debug!("ATTACH PEER_ID {:?}", remote_peer_id);
let already = self.peers.get(&(None, remote_peer_id));
if (already.is_some()) {
if already.is_some() {
match already.unwrap().connected {
PeerConnection::NONE => {}
_ => {
@ -923,11 +914,11 @@ impl<'a> Broker<'a> {
}
pub fn print_status(&self) {
self.peers.iter().for_each(|(peerId, peerInfo)| {
log_info!("PEER in BROKER {:?} {:?}", peerId, peerInfo);
self.peers.iter().for_each(|(peer_id, peer_info)| {
log_info!("PEER in BROKER {:?} {:?}", peer_id, peer_info);
});
self.direct_connections.iter().for_each(|(ip, directCnx)| {
log_info!("direct_connection in BROKER {:?} {:?}", ip, directCnx);
self.direct_connections.iter().for_each(|(ip, direct_cnx)| {
log_info!("direct_connection in BROKER {:?} {:?}", ip, direct_cnx);
});
self.anonymous_connections.iter().for_each(|(binds, cb)| {
log_info!(

@ -23,14 +23,12 @@ use crate::errors::NetError;
use crate::errors::ProtocolError;
use crate::types::*;
use crate::utils::*;
use async_std::future::TimeoutError;
use async_std::stream::StreamExt;
use async_std::sync::Mutex;
use either::Either;
use futures::{channel::mpsc, select, Future, FutureExt, SinkExt};
use noise_protocol::U8Array;
use futures::{channel::mpsc, select, FutureExt, SinkExt};
use noise_protocol::{patterns::noise_xk, CipherState, HandshakeState};
use noise_rust_crypto::sensitive::Sensitive;
use noise_rust_crypto::*;
use p2p_repo::log::*;
use p2p_repo::types::{PrivKey, PubKey, X25519PrivKey};
@ -260,7 +258,7 @@ impl NoiseFSM {
.as_mut()
.unwrap()
.decrypt_vec(ciphertext.data())
.map_err(|e| ProtocolError::DecryptionError)?;
.map_err(|_e| ProtocolError::DecryptionError)?;
Ok(from_slice::<ProtocolMessage>(&ser)?)
}
@ -288,13 +286,13 @@ impl NoiseFSM {
self.sender
.send(ConnectionCommand::Msg(ProtocolMessage::Noise(cipher)))
.await
.map_err(|e| ProtocolError::IoError)?;
.map_err(|_e| ProtocolError::IoError)?;
return Ok(());
} else {
self.sender
.send(ConnectionCommand::Msg(msg))
.await
.map_err(|e| ProtocolError::IoError)?;
.map_err(|_e| ProtocolError::IoError)?;
return Ok(());
}
}
@ -351,7 +349,7 @@ impl NoiseFSM {
let _ = handshake
.read_message_vec(noise.data())
.map_err(|e| ProtocolError::NoiseHandshakeFailed)?;
.map_err(|_e| ProtocolError::NoiseHandshakeFailed)?;
if !handshake.completed() {
return Err(ProtocolError::NoiseHandshakeFailed);
@ -394,14 +392,14 @@ impl NoiseFSM {
// CLIENT LOCAL
if !self.dir.is_server() && msg_opt.is_none() {
self.state = FSMstate::ClientHello;
Box::new(Actor::<ClientHello, ServerHello>::new(0, true));
//Box::new(Actor::<ClientHello, ServerHello>::new(0, true));
return Ok(StepReply::NONE);
}
// SERVER LOCAL
else if let Some(msg) = msg_opt.as_ref() {
if self.dir.is_server() && msg.type_id() == ClientHello::Local.type_id() {
self.state = FSMstate::ServerHello;
Box::new(Actor::<ClientHello, ServerHello>::new(msg.id(), false));
//Box::new(Actor::<ClientHello, ServerHello>::new(msg.id(), false));
return Ok(StepReply::NONE);
}
}
@ -417,7 +415,7 @@ impl NoiseFSM {
self.state = FSMstate::Probe;
return Ok(StepReply::NONE);
}
StartConfig::Relay(relay_to) => {
StartConfig::Relay(_relay_to) => {
// RELAY REQUEST
//self.state
todo!();
@ -439,7 +437,7 @@ impl NoiseFSM {
let payload = handshake
.write_message_vec(&[])
.map_err(|e| ProtocolError::NoiseHandshakeFailed)?;
.map_err(|_e| ProtocolError::NoiseHandshakeFailed)?;
let noise = Noise::V0(NoiseV0 { data: payload });
self.send(noise.into()).await?;
@ -514,7 +512,7 @@ impl NoiseFSM {
if id != 0 {
return Err(ProtocolError::InvalidState);
}
if let ProtocolMessage::ProbeResponse(probe_res) = &msg {
if let ProtocolMessage::ProbeResponse(_probe_res) = &msg {
return Ok(StepReply::Response(msg));
}
}
@ -537,7 +535,7 @@ impl NoiseFSM {
let mut payload = handshake
.read_message_vec(noise.data())
.map_err(|e| ProtocolError::NoiseHandshakeFailed)?;
.map_err(|_e| ProtocolError::NoiseHandshakeFailed)?;
payload = handshake.write_message_vec(&payload).map_err(|e| {
log_debug!("{:?}", e);
@ -552,19 +550,19 @@ impl NoiseFSM {
let mut next_step = StepReply::NONE;
match self.config.as_ref().unwrap() {
StartConfig::Client(client_config) => {
StartConfig::Client(_client_config) => {
let noise3 =
ClientHello::Noise3(Noise::V0(NoiseV0 { data: payload }));
self.send(noise3.into()).await?;
self.state = FSMstate::ClientHello;
}
StartConfig::Ext(ext_config) => {
StartConfig::Ext(_ext_config) => {
todo!();
}
StartConfig::Core(core_config) => {
StartConfig::Core(_core_config) => {
todo!();
}
StartConfig::Admin(admin_config) => {
StartConfig::Admin(_admin_config) => {
let noise = Noise::V0(NoiseV0 { data: payload });
self.send(noise.into()).await?;
self.state = FSMstate::Noise3;
@ -623,10 +621,10 @@ impl NoiseFSM {
StartConfig::Client(_) => {
return Err(ProtocolError::InvalidState);
}
StartConfig::Ext(ext_config) => {
StartConfig::Ext(_ext_config) => {
todo!();
}
StartConfig::Core(core_config) => {
StartConfig::Core(_core_config) => {
todo!();
}
StartConfig::Admin(admin_config) => {
@ -656,7 +654,7 @@ impl NoiseFSM {
StartProtocol::Client(_) => {
return Err(ProtocolError::InvalidState);
}
StartProtocol::Ext(ext_config) => {
StartProtocol::Ext(_ext_config) => {
todo!();
}
// StartProtocol::Core(core_config) => {
@ -730,8 +728,7 @@ impl NoiseFSM {
}
}
}
FSMstate::ServerHello =>
{
FSMstate::ServerHello => {
#[cfg(not(target_arch = "wasm32"))]
if let Some(msg) = msg_opt.as_ref() {
if self.dir.is_server() {
@ -742,7 +739,7 @@ impl NoiseFSM {
let ser = serde_bare::to_vec(&client_auth.content_v0())?;
let mut result = ProtocolError::NoError;
let result; //= ProtocolError::NoError;
let verif = verify(&ser, client_auth.sig(), client_auth.user());
if verif.is_err() {
result = verif.unwrap_err().into();
@ -768,7 +765,7 @@ impl NoiseFSM {
});
self.send(auth_result.into()).await?;
if (result.is_err()) {
if result.is_err() {
return Err(result);
}
log_debug!("AUTHENTICATION SUCCESSFUL ! waiting for requests on the server side");
@ -782,7 +779,7 @@ impl NoiseFSM {
if let Some(msg) = msg_opt.as_ref() {
if !self.dir.is_server() {
if let ProtocolMessage::AuthResult(auth_res) = msg {
if let StartConfig::Client(client_config) =
if let StartConfig::Client(_client_config) =
self.config.as_ref().unwrap()
{
if auth_res.result() != 0 {
@ -930,7 +927,7 @@ impl ConnectionBase {
log_debug!("EXIT READ LOOP because : {:?}", msg);
let mut lock = actors.lock().await;
for actor in lock.values_mut() {
actor.send(msg.clone()).await;
_ = actor.send(msg.clone()).await;
}
break;
}
@ -1146,7 +1143,7 @@ impl ConnectionBase {
self.close().await;
return Err(ProtocolError::WhereIsTheMagic);
},
r = shutdown.next().fuse() => {
_r = shutdown.next().fuse() => {
self.fsm
.as_mut()
.unwrap()
@ -1230,11 +1227,11 @@ impl ConnectionBase {
}
}
#[cfg(test)]
mod test {
use crate::actor::*;
use crate::actors::*;
use crate::types::*;
use p2p_repo::log::*;
use std::any::{Any, TypeId};

@ -12,10 +12,7 @@ use num_enum::IntoPrimitive;
use num_enum::TryFromPrimitive;
use p2p_repo::object::ObjectParseError;
use p2p_repo::store::StorageError;
use p2p_repo::types::Block;
use p2p_repo::types::ObjectId;
use std::convert::From;
use std::convert::TryFrom;
use std::error::Error;
#[derive(Debug, Eq, PartialEq, TryFromPrimitive, IntoPrimitive, Clone)]
@ -143,19 +140,19 @@ impl From<p2p_repo::errors::NgError> for ProtocolError {
}
impl From<ObjectParseError> for ProtocolError {
fn from(e: ObjectParseError) -> Self {
fn from(_e: ObjectParseError) -> Self {
ProtocolError::ObjectParseError
}
}
impl From<serde_bare::error::Error> for ProtocolError {
fn from(e: serde_bare::error::Error) -> Self {
fn from(_e: serde_bare::error::Error) -> Self {
ProtocolError::SerializationError
}
}
impl From<serde_bare::error::Error> for NetError {
fn from(e: serde_bare::error::Error) -> Self {
fn from(_e: serde_bare::error::Error) -> Self {
NetError::SerializationError
}
}

@ -8,8 +8,8 @@
* notice may not be copied, modified, or distributed except
* according to those terms.
*/
#[macro_use]
extern crate p2p_repo;
//#[macro_use]
//extern crate p2p_repo;
pub mod types;

@ -12,16 +12,15 @@
//! Corresponds to the BARE schema
use crate::utils::{
get_domain_without_port, get_domain_without_port_443, is_ipv4_private, is_ipv6_private,
is_private_ip, is_public_ip, is_public_ipv4, is_public_ipv6,
get_domain_without_port_443, is_ipv4_private, is_ipv6_private, is_private_ip, is_public_ip,
is_public_ipv4, is_public_ipv6,
};
use crate::{actor::EActor, actors::*, errors::ProtocolError};
use core::fmt;
use p2p_repo::errors::NgError;
use p2p_repo::log::*;
use p2p_repo::types::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::{
any::{Any, TypeId},
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
@ -157,6 +156,7 @@ pub const APP_NG_ONE_URL: &str = "https://app.nextgraph.one";
pub const APP_NG_ONE_WS_URL: &str = "wss://app.nextgraph.one";
#[allow(dead_code)]
fn api_dyn_peer_url(peer_id: &PubKey) -> String {
format!("https://nextgraph.one/api/v1/dynpeer/{}", peer_id)
}
@ -328,7 +328,6 @@ impl BrokerServerV0 {
None
}
}
_ => None,
}
}
@ -867,8 +866,8 @@ impl AcceptForwardForV0 {
pub fn get_public_bind_ipv6_address(&self) -> Option<IP> {
match self {
AcceptForwardForV0::PublicStatic((ipv4, ipv6, _)) => {
let mut res = vec![ipv4.clone()];
AcceptForwardForV0::PublicStatic((_ipv4, ipv6, _)) => {
//let _res = vec![ipv4.clone()];
if ipv6.is_some() {
return Some(ipv6.unwrap().ip.clone());
} else {
@ -1087,7 +1086,6 @@ impl ListenerV0 {
res.push(BrokerServerTypeV0::BoxPrivate(addrs));
}
}
_ => panic!("get_bootstrap missing"),
}
res
}

@ -9,16 +9,13 @@
* according to those terms.
*/
use crate::broker::BROKER;
use crate::types::*;
use crate::NG_BOOTSTRAP_LOCAL_PATH;
use async_std::task;
use ed25519_dalek::*;
use futures::{channel::mpsc, select, Future, FutureExt, SinkExt};
use futures::{channel::mpsc, Future};
use noise_protocol::U8Array;
use noise_protocol::DH;
use noise_rust_crypto::sensitive::Sensitive;
use p2p_repo::errors::NgError;
use p2p_repo::types::PubKey;
use p2p_repo::{log::*, types::PrivKey};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
@ -54,9 +51,11 @@ where
})
}
#[cfg(target_arch = "wasm32")]
#[cfg(debug_assertions)]
const APP_PREFIX: &str = "http://localhost:14400";
#[cfg(target_arch = "wasm32")]
#[cfg(not(debug_assertions))]
const APP_PREFIX: &str = "";

@ -9,10 +9,9 @@
//! Branch of a Repository
use crate::log::*;
use std::collections::HashSet;
use fastbloom_rs::{BloomFilter as Filter, Membership};
// use fastbloom_rs::{BloomFilter as Filter, Membership};
use crate::object::*;
use crate::store::*;
@ -145,17 +144,16 @@ impl Branch {
}
}
#[cfg(test)]
mod test {
use std::collections::HashMap;
//use fastbloom_rs::{BloomFilter as Filter, FilterBuilder, Membership};
use crate::branch::*;
use crate::commit::*;
use crate::object::*;
use crate::repo;
use crate::repo::Repo;
use crate::store::*;
use crate::log::*;
use crate::utils::*;
#[test]
@ -441,7 +439,7 @@ mod test {
repo.get_store(),
);
let mut c7 = Commit::load(a7.clone(), repo.get_store(), true).unwrap();
let c7 = Commit::load(a7.clone(), repo.get_store(), true).unwrap();
c7.verify(&repo).unwrap();
// let mut filter = Filter::new(FilterBuilder::new(10, 0.01));

@ -14,7 +14,7 @@ use core::fmt;
use once_cell::sync::OnceCell;
use crate::errors::NgError;
use crate::log::*;
use crate::object::*;
use crate::repo::Repo;
use crate::store::*;
@ -349,7 +349,6 @@ impl Commit {
Some(CommitHeaderKeys::V0(hk)) => hk.acks.is_empty() && hk.nacks.is_empty(),
None => true,
},
_ => unimplemented!(),
}
}
@ -368,7 +367,6 @@ impl Commit {
},
None => {}
},
_ => {}
};
res
}
@ -388,7 +386,6 @@ impl Commit {
},
None => {}
},
_ => {}
};
res
}
@ -413,7 +410,6 @@ impl Commit {
}
_ => {}
},
_ => {}
};
res
}
@ -1121,14 +1117,10 @@ impl fmt::Display for CommitHeaderKeys {
}
}
#[cfg(test)]
mod test {
use std::collections::HashMap;
use crate::branch::*;
use crate::commit::*;
use crate::store::*;
use crate::types::*;
use crate::utils::*;
use crate::log::*;
#[test]
pub fn test_commit() {

@ -36,19 +36,19 @@ impl fmt::Display for NgError {
}
impl From<serde_bare::error::Error> for NgError {
fn from(e: serde_bare::error::Error) -> Self {
fn from(_e: serde_bare::error::Error) -> Self {
NgError::SerializationError
}
}
impl From<ed25519_dalek::ed25519::Error> for NgError {
fn from(e: ed25519_dalek::ed25519::Error) -> Self {
fn from(_e: ed25519_dalek::ed25519::Error) -> Self {
NgError::InvalidSignature
}
}
impl From<CommitLoadError> for NgError {
fn from(e: CommitLoadError) -> Self {
fn from(_e: CommitLoadError) -> Self {
NgError::RepoLoadError
}
}

@ -293,7 +293,7 @@ impl Object {
/// * `store_secret`: store's read capability secret, needed to generate the convergence key
pub fn new(
content: ObjectContent,
mut header: Option<CommitHeader>,
header: Option<CommitHeader>,
block_size: usize,
store: &StoreRepo,
store_secret: &ReadCapSecret,
@ -512,7 +512,7 @@ impl Object {
Ok(ObjectContent::V0(ObjectContentV0::CommitHeader(commit_header))) => {
(Some(commit_header), None)
}
Err(e) => return Err(ObjectParseError::InvalidHeader),
Err(_e) => return Err(ObjectParseError::InvalidHeader),
_ => return Err(ObjectParseError::InvalidHeader),
}
}
@ -688,7 +688,8 @@ impl Object {
if leaves.is_none() && obj_content.is_none() {
// we just want to calculate the depth. no need to decrypt
for id in b_children {
children.push((id.clone(), ObjectKey::dummy()));
#[allow(deprecated)]
children.push((id.clone(), ObjectKey::nil()));
}
continue;
}
@ -828,7 +829,6 @@ impl Object {
match self.content() {
Ok(ObjectContent::V0(v0)) => Ok(v0),
Err(e) => Err(e),
_ => unimplemented!(),
}
}
}
@ -877,7 +877,7 @@ impl ObjectContent {
}
}
pub fn new_file_V0_with_content(content: Vec<u8>, content_type: &str) -> Self {
pub fn new_file_v0_with_content(content: Vec<u8>, content_type: &str) -> Self {
ObjectContent::V0(ObjectContentV0::File(File::V0(FileV0 {
content_type: content_type.into(),
metadata: vec![],
@ -916,8 +916,6 @@ impl fmt::Display for ObjectContent {
mod test {
use crate::object::*;
use crate::store::*;
use crate::types::*;
use std::io::BufReader;
use std::io::Read;
use std::io::Write;
@ -968,7 +966,7 @@ mod test {
reader
.read_to_end(&mut img_buffer)
.expect("read of test.jpg");
let content = ObjectContent::new_file_V0_with_content(img_buffer, "image/jpeg");
let content = ObjectContent::new_file_v0_with_content(img_buffer, "image/jpeg");
let max_object_size = store_max_value_size();
let (store_repo, store_secret) = StoreRepo::dummy_public_v0();
@ -1696,69 +1694,5 @@ mod test {
test_block(store_valid_value_size(100000));
test_block(store_valid_value_size(1000000));
test_block(store_valid_value_size(5000));
///////////////////
/*
let max_arity_leaves = (max_block_size - EMPTY_BLOCK_SIZE - BIG_VARINT_EXTRA * 2)
/ (BLOCK_ID_SIZE + BLOCK_KEY_SIZE);
log_debug!("max_arity_leaves: {}", max_arity_leaves);
assert_eq!(max_arity_leaves, MAX_ARITY_LEAVES);
assert_eq!(
max_block_size - EMPTY_BLOCK_SIZE - DATA_VARINT_EXTRA,
max_data_payload_size
);
let max_arity_root =
(max_block_size - EMPTY_BLOCK_SIZE - MAX_HEADER_SIZE - BIG_VARINT_EXTRA * 2)
/ (BLOCK_ID_SIZE + BLOCK_KEY_SIZE);
log_debug!("max_arity_root: {}", max_arity_root);
assert_eq!(max_arity_root, MAX_ARITY_ROOT);
log_debug!("store_max_value_size: {}", leaf_full_data_ser.len());
assert_eq!(leaf_full_data_ser.len(), max_block_size);
log_debug!("leaf_empty: {}", leaf_empty_ser.len());
assert_eq!(leaf_empty_ser.len(), EMPTY_BLOCK_SIZE);
// log_debug!("root_depsref: {}", root_depsref_ser.len());
// assert_eq!(root_depsref_ser.len(), EMPTY_ROOT_SIZE_DEPSREF);
log_debug!("internal_max: {}", internal_max_ser.len());
assert_eq!(
internal_max_ser.len(),
EMPTY_BLOCK_SIZE
+ BIG_VARINT_EXTRA * 2
+ MAX_ARITY_LEAVES * (BLOCK_ID_SIZE + BLOCK_KEY_SIZE)
);
assert!(internal_max_ser.len() < max_block_size);
log_debug!("internal_one: {}", internal_one_ser.len());
assert_eq!(
internal_one_ser.len(),
EMPTY_BLOCK_SIZE + 1 * BLOCK_ID_SIZE + 1 * BLOCK_KEY_SIZE
);
log_debug!("internal_two: {}", internal_two_ser.len());
assert_eq!(
internal_two_ser.len(),
EMPTY_BLOCK_SIZE + 2 * BLOCK_ID_SIZE + 2 * BLOCK_KEY_SIZE
);
log_debug!("root_one: {}", root_one_ser.len());
assert_eq!(
root_one_ser.len(),
EMPTY_BLOCK_SIZE + 8 * BLOCK_ID_SIZE + 1 * BLOCK_ID_SIZE + 1 * BLOCK_KEY_SIZE
);
log_debug!("root_two: {}", root_two_ser.len());
assert_eq!(
root_two_ser.len(),
EMPTY_BLOCK_SIZE + 8 * BLOCK_ID_SIZE + 2 * BLOCK_ID_SIZE + 2 * BLOCK_KEY_SIZE
);*/
// let object_size_1 = 4096 * 1 - VALUE_HEADER_SIZE;
// let object_size_512 = 4096 * MAX_PAGES_PER_VALUE - VALUE_HEADER_SIZE;
// let arity_1: usize =
// (object_size_1 - 8 * OBJECT_ID_SIZE) / (OBJECT_ID_SIZE + OBJECT_KEY_SIZE);
// let arity_512: usize =
// (object_size_512 - 8 * OBJECT_ID_SIZE) / (OBJECT_ID_SIZE + OBJECT_KEY_SIZE);
// log_debug!("1-page object_size: {}", object_size_1);
// log_debug!("512-page object_size: {}", object_size_512);
// log_debug!("max arity of 1-page object: {}", arity_1);
// log_debug!("max arity of 512-page object: {}", arity_512);
}
}

@ -42,20 +42,20 @@ impl SiteV0 {
pub write_cap: RepoWriteCapSecret, */
let public = SiteStore {
key: PrivKey::dummy(),
read_cap: BlockRef::dummy(),
key: PrivKey::nil(),
read_cap: BlockRef::nil(),
write_cap: SymKey::random(),
};
let protected = SiteStore {
key: PrivKey::dummy(),
read_cap: BlockRef::dummy(),
key: PrivKey::nil(),
read_cap: BlockRef::nil(),
write_cap: SymKey::random(),
};
let private = SiteStore {
key: PrivKey::dummy(),
read_cap: BlockRef::dummy(),
key: PrivKey::nil(),
read_cap: BlockRef::nil(),
write_cap: SymKey::random(),
};

@ -13,13 +13,12 @@
use futures::StreamExt;
use crate::log::*;
use crate::types::*;
use crate::utils::Receiver;
use std::sync::{Arc, RwLock};
use std::sync::RwLock;
use std::{
cmp::{max, min},
collections::{hash_map::Iter, HashMap},
collections::HashMap,
mem::size_of_val,
};
@ -55,7 +54,7 @@ impl core::fmt::Display for StorageError {
}
impl From<serde_bare::error::Error> for StorageError {
fn from(e: serde_bare::error::Error) -> Self {
fn from(_e: serde_bare::error::Error) -> Self {
StorageError::SerializationError
}
}

@ -19,8 +19,6 @@ use crate::utils::{
use core::fmt;
use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize};
use serde_bare::to_vec;
use std::collections::{HashMap, HashSet};
use std::hash::Hash;
use zeroize::{Zeroize, ZeroizeOnDrop};
@ -86,7 +84,11 @@ impl SymKey {
pub fn from_array(array: [u8; 32]) -> Self {
SymKey::ChaCha20Key(array)
}
#[deprecated(note = "**Don't use dummy method**")]
#[deprecated(note = "**Don't use nil method**")]
pub fn nil() -> Self {
SymKey::ChaCha20Key([0; 32])
}
#[cfg(test)]
pub fn dummy() -> Self {
SymKey::ChaCha20Key([0; 32])
}
@ -151,6 +153,8 @@ impl PubKey {
_ => panic!("can only convert an edward key to montgomery"),
}
}
#[deprecated(note = "**Don't use nil method**")]
pub fn nil() -> Self {
PubKey::Ed25519PubKey([0u8; 32])
}
@ -194,7 +198,12 @@ impl PrivKey {
}
}
#[deprecated(note = "**Don't use dummy method**")]
#[deprecated(note = "**Don't use nil method**")]
pub fn nil() -> PrivKey {
PrivKey::Ed25519PrivKey([0u8; 32])
}
#[cfg(test)]
pub fn dummy() -> PrivKey {
PrivKey::Ed25519PrivKey([0u8; 32])
}
@ -267,9 +276,6 @@ impl fmt::Display for Sig {
base64_url::encode(&ed[1])
)
}
_ => {
unimplemented!();
}
}
}
}
@ -362,20 +368,34 @@ pub struct BlockRef {
}
impl BlockId {
#[deprecated(note = "**Don't use dummy method**")]
#[cfg(test)]
pub fn dummy() -> Self {
Digest::Blake3Digest32([0u8; 32])
}
#[deprecated(note = "**Don't use nil method**")]
pub fn nil() -> Self {
Digest::Blake3Digest32([0u8; 32])
}
}
impl BlockRef {
#[deprecated(note = "**Don't use dummy method**")]
#[cfg(test)]
pub fn dummy() -> Self {
BlockRef {
id: Digest::Blake3Digest32([0u8; 32]),
key: SymKey::ChaCha20Key([0u8; 32]),
}
}
#[deprecated(note = "**Don't use nil method**")]
pub fn nil() -> Self {
BlockRef {
id: Digest::Blake3Digest32([0u8; 32]),
key: SymKey::ChaCha20Key([0u8; 32]),
}
}
pub fn from_id_key(id: BlockId, key: BlockKey) -> Self {
BlockRef { id, key }
}
@ -508,6 +528,8 @@ impl StoreRepo {
},
}
}
#[cfg(test)]
#[allow(deprecated)]
pub fn dummy_public_v0() -> (Self, SymKey) {
let readcap = SymKey::dummy();
let store_pubkey = PubKey::nil();
@ -1464,10 +1486,10 @@ pub struct CertificateContentV0 {
pub readcap_id: ObjectId,
/// PublicKey Set used by the Owners. verifier uses this PKset if the signature was issued by the Owners.
pub owners_PKset: threshold_crypto::PublicKeySet,
pub owners_pk_set: threshold_crypto::PublicKeySet,
/// two "orders" PublicKey Sets (total_order and partial_order).
pub orders_PKsets: OrdersPublicKeySetsV0,
pub orders_pk_sets: OrdersPublicKeySetsV0,
}
/// A Signature of a Certificate and the threshold set or public key used to generate it

Loading…
Cancel
Save