diff --git a/src/types/errors.rs b/src/types/errors.rs index 82307c113f..3c1c69b649 100644 --- a/src/types/errors.rs +++ b/src/types/errors.rs @@ -21,7 +21,7 @@ use thiserror::Error; pub type Result = result::Result; /// Error debug struct -pub struct ErrorDebug<'a, T>(pub &'a Result); +struct ErrorDebug<'a, T>(&'a Result); impl<'a, T> Debug for ErrorDebug<'a, T> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { diff --git a/src/types/keys/mod.rs b/src/types/keys/mod.rs index 2ae907cb40..495fa8c8ee 100644 --- a/src/types/keys/mod.rs +++ b/src/types/keys/mod.rs @@ -13,14 +13,8 @@ //! `new` functions. A `PublicKey` can't be generated by itself; it must always be derived from a //! secret key. -mod keypair; -mod node_keypairs; -mod public_key; -mod secret_key; -mod signature; - -pub use self::signature::*; -pub use keypair::*; -pub use node_keypairs::*; -pub use public_key::*; -pub use secret_key::*; +pub(super) mod keypair; +pub(super) mod node_keypairs; +pub(super) mod public_key; +pub(super) mod secret_key; +pub(super) mod signature; diff --git a/src/types/keys/node_keypairs.rs b/src/types/keys/node_keypairs.rs index f3d520ce60..bdbc2a7d44 100644 --- a/src/types/keys/node_keypairs.rs +++ b/src/types/keys/node_keypairs.rs @@ -7,8 +7,8 @@ // specific language governing permissions and limitations relating to use of the SAFE Network // Software. -use super::super::keys::{BlsKeypairShare, SignatureShare}; use super::super::{PublicKey, Signature}; +use crate::types::{BlsKeypairShare, SignatureShare}; use bls::{serde_impl::SerdeSecret, PublicKeySet, SecretKeyShare as BlsSecretKeyShare}; use ed25519_dalek::Keypair as Ed25519Keypair; use rand::{CryptoRng, Rng}; diff --git a/src/types/keys/public_key.rs b/src/types/keys/public_key.rs index 20d14292f1..0b15b92974 100644 --- a/src/types/keys/public_key.rs +++ b/src/types/keys/public_key.rs @@ -279,7 +279,7 @@ pub(crate) mod tests { ] } - pub fn gen_keys() -> Vec { + pub(crate) fn gen_keys() -> Vec { gen_keypairs().iter().map(PublicKey::from).collect() } diff --git a/src/types/mod.rs b/src/types/mod.rs index 11d70a06a4..043558377b 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -28,8 +28,11 @@ pub use chunk::{ }; pub use errors::{Error, Result}; pub use keys::{ - BlsKeypairShare, Keypair, NodeKeypairs, OwnerType, PublicKey, SecretKey, Signature, - SignatureShare, Signing, + keypair::{BlsKeypairShare, Keypair, OwnerType, Signing}, + node_keypairs::NodeKeypairs, + public_key::PublicKey, + secret_key::SecretKey, + signature::{Signature, SignatureShare}, }; pub use map::{ Action as MapAction, Address as MapAddress, Entries as MapEntries, @@ -39,12 +42,15 @@ pub use map::{ pub use register::Address as RegisterAddress; pub use section::SectionElders; pub use sequence::{ - Action as SequenceAction, Address as SequenceAddress, Data as Sequence, DataOp as SequenceOp, - Entries as SequenceEntries, Entry as SequenceEntry, Index as SequenceIndex, - Kind as SequenceKind, Permissions as SequencePermissions, Policy as SequencePolicy, - PrivatePermissions as SequencePrivatePermissions, PrivatePolicy as SequencePrivatePolicy, - PrivateSeqData, PublicPermissions as SequencePublicPermissions, - PublicPolicy as SequencePublicPolicy, PublicSeqData, User as SequenceUser, + metadata::{ + Action as SequenceAction, Address as SequenceAddress, Entries as SequenceEntries, + Entry as SequenceEntry, Index as SequenceIndex, Kind as SequenceKind, + Permissions as SequencePermissions, Policy as SequencePolicy, + PrivatePermissions as SequencePrivatePermissions, PrivatePolicy as SequencePrivatePolicy, + PublicPermissions as SequencePublicPermissions, PublicPolicy as SequencePublicPolicy, + User as SequenceUser, + }, + Data as Sequence, DataOp as SequenceOp, PrivateSeqData, PublicSeqData, }; pub use token::Token; diff --git a/src/types/register/reg_crdt.rs b/src/types/register/reg_crdt.rs index 7ec066a130..e6cc6f4aef 100644 --- a/src/types/register/reg_crdt.rs +++ b/src/types/register/reg_crdt.rs @@ -38,7 +38,7 @@ pub struct CrdtOperation { /// Register data type as a CRDT with Access Control #[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd)] -pub struct RegisterCrdt { +pub(super) struct RegisterCrdt { /// Address on the network of this piece of data address: Address, /// CRDT to store the actual data, i.e. the items of the Register. @@ -60,7 +60,7 @@ impl Display for RegisterCrdt { impl RegisterCrdt { /// Constructs a new 'RegisterCrdt'. - pub fn new(address: Address) -> Self { + pub(super) fn new(address: Address) -> Self { Self { address, data: MerkleReg::new(), @@ -68,18 +68,18 @@ impl RegisterCrdt { } /// Returns the address. - pub fn address(&self) -> &Address { + pub(super) fn address(&self) -> &Address { &self.address } /// Returns total number of items in the register. - pub fn size(&self) -> u64 { + pub(super) fn size(&self) -> u64 { (self.data.num_nodes() + self.data.num_orphans()) as u64 } /// Write a new entry to the RegisterCrdt, returning the hash /// of the entry and the CRDT operation without a signature - pub fn write( + pub(super) fn write( &mut self, entry: Entry, parents: BTreeSet, @@ -103,7 +103,7 @@ impl RegisterCrdt { } /// Apply a remote data CRDT operation to this replica of the RegisterCrdt. - pub fn apply_op(&mut self, op: CrdtOperation) -> Result<()> { + pub(super) fn apply_op(&mut self, op: CrdtOperation) -> Result<()> { // Let's first check the op is validly signed. // Note: Perms for the op are checked at the upper Register layer. let sig = op.signature.ok_or(Error::CrdtMissingOpSignature)?; @@ -127,12 +127,12 @@ impl RegisterCrdt { } /// Get the entry corresponding to the provided `hash` if it exists. - pub fn get(&self, hash: EntryHash) -> Option<&Entry> { + pub(super) fn get(&self, hash: EntryHash) -> Option<&Entry> { self.data.node(hash).map(|node| &node.value) } /// Read the last entry, or entries if there are branches. - pub fn read(&self) -> BTreeSet<(EntryHash, Entry)> { + pub(super) fn read(&self) -> BTreeSet<(EntryHash, Entry)> { self.data .read() .hashes_and_nodes() diff --git a/src/types/sequence/mod.rs b/src/types/sequence/mod.rs index 9f00c62bdf..0f5adb8731 100644 --- a/src/types/sequence/mod.rs +++ b/src/types/sequence/mod.rs @@ -7,13 +7,13 @@ // specific language governing permissions and limitations relating to use of the SAFE Network // Software. -mod metadata; +pub(super) mod metadata; mod seq_crdt; use super::{Error, PublicKey, Result}; -pub use metadata::{ - Action, Address, Entries, Entry, Index, Kind, Perm, Permissions, Policy, PrivatePermissions, - PrivatePolicy, PublicPermissions, PublicPolicy, User, +use metadata::{ + Action, Address, Entries, Entry, Index, Kind, Perm, Permissions, PrivatePolicy, PublicPolicy, + User, }; use seq_crdt::{CrdtOperation, SequenceCrdt}; use serde::{Deserialize, Serialize}; diff --git a/src/types/sequence/seq_crdt.rs b/src/types/sequence/seq_crdt.rs index 2eb395ece1..a6ce2000b3 100644 --- a/src/types/sequence/seq_crdt.rs +++ b/src/types/sequence/seq_crdt.rs @@ -10,8 +10,10 @@ use super::super::{utils, Error, PublicKey, Result, Signature}; use super::metadata::Entries; use super::metadata::{Address, Entry, Index, Perm}; -pub use crdts::list::Op; -use crdts::{list::List, CmRDT}; +use crdts::{ + list::{List, Op}, + CmRDT, +}; use serde::{Deserialize, Serialize}; use std::{ fmt::{self, Debug, Display},