Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
chore(name): update routing repo/crate name to sn_routing
Browse files Browse the repository at this point in the history
Also includes some minor cargo fmt suggestions
  • Loading branch information
S-Coyle committed Sep 15, 2020
1 parent f426da6 commit 583f7f9
Show file tree
Hide file tree
Showing 31 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Routing - Change Log
# sn_routing - Change Log

## [0.37.0]
- Upgrade unwrap version to 1.2.0
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
authors = ["MaidSafe Developers <dev@maidsafe.net>"]
description = "A secured storage DHT"
documentation = "https://docs.rs/routing"
documentation = "https://docs.rs/sn_routing"
homepage = "https://maidsafe.net"
license = "GPL-3.0"
name = "routing"
name = "sn_routing"
readme = "README.md"
repository = "https://github.com/maidsafe/routing"
repository = "https://github.com/maidsafe/sn_routing"
version = "0.37.0"
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LINKING EXCEPTION

Routing is distributed under the terms of the GNU General Public
sn_routing is distributed under the terms of the GNU General Public
License (v3) with the following clarification and special exception.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Routing
# sn_routing

Routing - a specialised storage DHT
sn_routing - a specialised storage DHT

|Crate|LoC|
|:---:|:--:|
|[![](http://meritbadge.herokuapp.com/routing)](https://crates.io/crates/routing)|[![LoC](https://tokei.rs/b1/github/maidsafe/routing)](https://github.com/maidsafe/routing)|
|[![](http://meritbadge.herokuapp.com/sn_routing)](https://crates.io/crates/sn_routing)|[![LoC](https://tokei.rs/b1/github/maidsafe/sn_routing)](https://github.com/maidsafe/sn_routing)|

| [Documentation](https://maidsafe.github.io/routing/routing) | [MaidSafe website](https://maidsafe.net) | [SAFE Dev Forum](https://forum.safedev.org) | [SAFE Network Forum](https://safenetforum.org) |
| [Documentation](https://maidsafe.github.io/sn_routing/sn_routing) | [MaidSafe website](https://maidsafe.net) | [Safe Dev Forum](https://forum.safedev.org) | [Safe Network Forum](https://safenetforum.org) |
|:----------------------------------------:|:----------------------------------------:|:-------------------------------------------:|:----------------------------------------------:|

## Overview
Expand All @@ -16,7 +16,7 @@ A secured [DHT](http://en.wikipedia.org/wiki/Distributed_hash_table), based on a
This library makes use of [Public-key cryptography](http://en.wikipedia.org/wiki/Public-key_cryptography) to allow a mechanism to ensure nodes are well recognised and cryptographically secured. This pattern
allows the creation of a DHT based PKI and this in turn allows a decentralised network to make use of groups as fixed in relation to any address. This is particularly useful in a continually fluid network as described [here,](http://docs.maidsafe.net/Whitepapers/pdf/MaidSafeDistributedHashTable.pdf) creating a server-less and [autonomous network](http://docs.maidsafe.net/Whitepapers/pdf/TheSafeNetwork.pdf).

This is a very under researched area. For a general introduction to some of the ideas behind the design related to XOR Space, watching [The SAFE Network from First Principles series](https://www.youtube.com/watch?v=Lr9FJRDcNzk&list=PLiYqQVdgdw_sSDkdIZzDRQR9xZlsukIxD) is recommended. The slides for XOR Distance Metric and Basic Routing lecture are also [available here](http://ericklavoie.com/talks/safenetwork/1-xor-routing.pdf). The last video from the series on how the same ideas were applied to decentralised BitTorrent trackers is available [here](https://www.youtube.com/watch?v=YFV908uoLPY). A proper formalisation of the Routing algorithm is in progress.
This is a very under researched area. For a general introduction to some of the ideas behind the design related to XOR Space, watching [The Safe Network from First Principles series](https://www.youtube.com/watch?v=Lr9FJRDcNzk&list=PLiYqQVdgdw_sSDkdIZzDRQR9xZlsukIxD) is recommended. The slides for XOR Distance Metric and Basic Routing lecture are also [available here](http://ericklavoie.com/talks/safenetwork/1-xor-routing.pdf). The last video from the series on how the same ideas were applied to decentralised BitTorrent trackers is available [here](https://www.youtube.com/watch?v=YFV908uoLPY). A proper formalisation of the Routing algorithm is in progress.

## Logging

Expand All @@ -25,16 +25,16 @@ via `env_logger`. By default this prints messages of level "warn" and higher
("error"), but not lower levels ("info", "debug", "trace"). The level can be set
explicitly (any of the above or "off"), e.g.:

export RUST_LOG=routing=info
export RUST_LOG=sn_routing=info

Optionally, the following sub-targets can be controlled independently:

* stats — messages about connections and routing table size
* stats — messages about connections and sn_routing table size
* crust — messages from the mock Crust layer (not real Crust)

Example:

export RUST_LOG=routing=info,stats=off
export RUST_LOG=sn_routing=info,stats=off


## License
Expand All @@ -43,7 +43,7 @@ Licensed under the General Public License (GPL), version 3 ([LICENSE](LICENSE) h

### Linking exception

Routing is licensed under GPLv3 with linking exception. This means you can link to and use the library from any program, proprietary or open source; paid or gratis. However, if you modify Routing, you must distribute the source to your modified version under the terms of the GPLv3.
sn_routing is licensed under GPLv3 with linking exception. This means you can link to and use the library from any program, proprietary or open source; paid or gratis. However, if you modify sn_routing, you must distribute the source to your modified version under the terms of the GPLv3.

See the LICENSE file for more details.

Expand Down
12 changes: 6 additions & 6 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use crossbeam_channel::{Receiver, Select, Sender};
use hex_fmt::HexFmt;
use log::LevelFilter;
use routing::{
use sn_routing::{
event::{Connected, Event},
Node, NodeConfig, TransportConfig,
};
Expand Down Expand Up @@ -206,7 +206,7 @@ fn start_node(
log::info!("Node #{} starting...", index);

// The returned triple is:
// - The routing node itself.
// - The sn_routing node itself.
// - The receiver for events that the node notifies the application about.
// - The receiver for client network events. We don't support clients in this example, so we
// can ignore it
Expand Down Expand Up @@ -373,7 +373,7 @@ fn handle_event(
}

const TARGET_SELF: &str = "minimal";
const TARGET_ROUTING: &str = "routing";
const TARGET_ROUTING: &str = "sn_routing";

fn init_log(verbosity: u8) {
let mut builder = env_logger::builder();
Expand All @@ -384,15 +384,15 @@ fn init_log(verbosity: u8) {
.filter(Some(TARGET_SELF), LevelFilter::Info);

if verbosity > 0 {
// Enable info logs from routing.
// Enable info logs from sn_routing.
builder.filter(Some(TARGET_ROUTING), LevelFilter::Info);
}
if verbosity > 1 {
// Enable debug logs from routing
// Enable debug logs from sn_routing
builder.filter(Some(TARGET_ROUTING), LevelFilter::Debug);
}
if verbosity > 2 {
// Enable trace logs from routing
// Enable trace logs from sn_routing
builder.filter(Some(TARGET_ROUTING), LevelFilter::Trace);
}
if verbosity > 3 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/fixup_check
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

output=$(git log --oneline origin/fleming.. | grep -iE 'fixup|wip')
output=$(git log --oneline origin/master.. | grep -iE 'fixup|wip')
if [[ $? != 1 ]]; then
echo "Found fixup or WIP commit(s):"
echo "$output"
Expand Down
12 changes: 6 additions & 6 deletions src/consensus/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Debug for DkgResult {
}

/// DKG voter carries out the work of voting for a DKG. Also contains the facility caches that
/// allows routing utilize the result properly within its churning process.
/// allows sn_routing utilize the result properly within its churning process.
pub struct DkgVoter {
// Holds the info of the expected new elders.
dkg_cache: BTreeMap<DkgKey, EldersInfo>,
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Default for DkgVoter {

impl DkgVoter {
// Check whether a key generator is finalized to give a DKG. Once a DKG is generated, the cached
// accumulated events shall be taken for routing (updated with new DKG) to process.
// accumulated events shall be taken for sn_routing (updated with new DKG) to process.
pub fn check_dkg(&mut self) -> (BTreeMap<DkgKey, DkgResult>, VecDeque<(Vote, Proof)>) {
let mut completed = BTreeMap::new();
for (key, key_gen) in self.key_gen_map.iter_mut() {
Expand Down Expand Up @@ -127,9 +127,9 @@ impl DkgVoter {
}

// Free key generators not newer than the current one.
// After a DKG completion, routing will carry out votes of OurKey and SectionInfo.
// After a DKG completion, sn_routing will carry out votes of OurKey and SectionInfo.
// Only after these votes got consensused, will then the section_key_index got updated.
// So, a routing level check of section_index will not be enough within the gap.
// So, a sn_routing level check of section_index will not be enough within the gap.
// i.e. any DKG message received during the gap will cause a new round of DKG for the same.
// Hence here the info of completed highest section_key_index shall be recorded and checked
// against to cover the gap.
Expand Down Expand Up @@ -221,7 +221,7 @@ impl DkgVoter {

// When a churn is noticed, the new EdlersInfo that calculated shall be recorded.
// In case we already have the correspondent DkgResult, the dkg_result shall be returned for
// routing to carry out further process.
// sn_routing to carry out further process.
pub fn push_info(&mut self, dkg_key: &DkgKey, info: EldersInfo) -> Option<DkgResult> {
let _ = self.dkg_cache.insert(dkg_key.clone(), info);

Expand All @@ -232,7 +232,7 @@ impl DkgVoter {
}
}

// Give the cached new EldersInfo to routing for its further process.
// Give the cached new EldersInfo to sn_routing for its further process.
pub fn take_info(&mut self, dkg_key: &DkgKey) -> Option<EldersInfo> {
self.dkg_cache.remove(dkg_key)
}
Expand Down
8 changes: 4 additions & 4 deletions src/delivery_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

//! Utilities for routing messages through the network.
//! Utilities for sn_routing messages through the network.
use crate::{
error::{Result, RoutingError},
error::{Result, SNRoutingError},
id::{P2pNode, PublicId},
location::DstLocation,
section::{SectionMap, SectionMembers},
Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn delivery_targets(

candidates(target_name, our_id, sections)?
}
DstLocation::Direct => return Err(RoutingError::CannotRoute),
DstLocation::Direct => return Err(SNRoutingError::CannotRoute),
};

Ok((best_section, dg_size))
Expand Down Expand Up @@ -123,7 +123,7 @@ fn candidates(
if dg_size > 0 && nodes_to_send.len() >= dg_size {
Ok((nodes_to_send, dg_size))
} else {
Err(RoutingError::CannotRoute)
Err(SNRoutingError::CannotRoute)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use crate::quic_p2p::QuicP2pError;
use err_derive::Error;

/// The type returned by the routing message handling methods.
pub type Result<T, E = RoutingError> = std::result::Result<T, E>;
/// The type returned by the sn_routing message handling methods.
pub type Result<T, E = SNRoutingError> = std::result::Result<T, E>;

/// Internal error.
#[derive(Debug, Error)]
#[allow(missing_docs)]
pub enum RoutingError {
pub enum SNRoutingError {
#[error(display = "Invalid requester or handler locations.")]
BadLocation,
#[error(display = "Failed signature check.")]
Expand Down
2 changes: 1 addition & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum Connected {

/// An Event raised by a `Node` or `Client` via its event sender.
///
/// These are sent by routing to the library's user. It allows the user to handle requests and
/// These are sent by sn_routing to the library's user. It allows the user to handle requests and
/// responses, and to react to changes in the network.
///
/// `Request` and `Response` events from section locations are only raised once the quorum has
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod macros;
// Public API
// ############################################################################
pub use self::{
error::RoutingError,
error::SNRoutingError,
id::{FullId, P2pNode, PublicId},
location::{DstLocation, SrcLocation},
network_params::NetworkParams,
Expand All @@ -91,7 +91,7 @@ pub use self::{
};

pub use xor_name::{Prefix, XorName, XOR_NAME_LEN}; // TODO remove pub on API update
/// Routing events.
/// sn_routing events.
pub mod event;

// ############################################################################
Expand Down Expand Up @@ -155,7 +155,7 @@ const QUORUM_NUMERATOR: usize = 2;
/// See `QUORUM_NUMERATOR`.
const QUORUM_DENOMINATOR: usize = 3;

/// Recommended section size. Routing will keep adding nodes until the section reaches this size.
/// Recommended section size. sn_routing will keep adding nodes until the section reaches this size.
/// More nodes might be added if requested by the upper layers.
/// This number also detemines when split happens - if both post-split sections would have at least
/// this number of nodes.
Expand Down
6 changes: 3 additions & 3 deletions src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use crate::error::{Result, RoutingError};
use crate::error::{Result, SNRoutingError};
use xor_name::{Prefix, XorName};

/// Message source location.
Expand Down Expand Up @@ -69,15 +69,15 @@ impl DstLocation {
pub(crate) fn as_node(&self) -> Result<&XorName> {
match self {
Self::Node(name) => Ok(name),
Self::Section(_) | Self::Direct => Err(RoutingError::BadLocation),
Self::Section(_) | Self::Direct => Err(SNRoutingError::BadLocation),
}
}

/// Returns `Ok` if this location is section, `Err(BadLocation)` otherwise.
pub(crate) fn check_is_section(&self) -> Result<()> {
match self {
Self::Section(_) => Ok(()),
Self::Node(_) | Self::Direct => Err(RoutingError::BadLocation),
Self::Node(_) | Self::Direct => Err(SNRoutingError::BadLocation),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/message_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl MessageFilter {
let _ = self.incoming.insert(*msg.hash(), ());
}

// Filter outgoing `RoutingMessage`. Return whether this specific message has been seen recently
// Filter outgoing `SNRoutingMessage`. Return whether this specific message has been seen recently
// (and thus should not be sent, due to deduplication).
//
pub fn filter_outgoing(&mut self, msg: &Message, pub_id: &PublicId) -> FilteringResult {
Expand Down
20 changes: 10 additions & 10 deletions src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) use self::{
};
pub use self::{hash::MessageHash, src_authority::SrcAuthority};
use crate::{
error::{Result, RoutingError},
error::{Result, SNRoutingError},
id::FullId,
location::DstLocation,
section::{ExtendError, SectionProofChain, TrustStatus},
Expand Down Expand Up @@ -177,7 +177,7 @@ impl Message {
signature,
} => {
if !public_id.verify(&bytes, signature) {
return Err(RoutingError::FailedSignature);
return Err(SNRoutingError::FailedSignature);
}

// Variant-specific verification.
Expand All @@ -192,11 +192,11 @@ impl Message {
let proof_chain = if let Some(proof_chain) = self.proof_chain.as_ref() {
proof_chain
} else {
return Err(RoutingError::InvalidMessage);
return Err(SNRoutingError::InvalidMessage);
};

if !proof_chain.last_key().verify(signature, &bytes) {
return Err(RoutingError::FailedSignature);
return Err(SNRoutingError::FailedSignature);
}

let trusted_keys = trusted_keys
Expand All @@ -207,7 +207,7 @@ impl Message {
match proof_chain.check_trust(trusted_keys) {
TrustStatus::Trusted => Ok(VerifyStatus::Full),
TrustStatus::Unknown => Ok(VerifyStatus::Unknown),
TrustStatus::Invalid => Err(RoutingError::UntrustedMessage),
TrustStatus::Invalid => Err(SNRoutingError::UntrustedMessage),
}
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ impl Message {
pub(crate) fn proof_chain(&self) -> Result<&SectionProofChain> {
self.proof_chain
.as_ref()
.ok_or(RoutingError::InvalidMessage)
.ok_or(SNRoutingError::InvalidMessage)
}

/// Returns the last key of the attached the proof chain, if any.
Expand Down Expand Up @@ -302,10 +302,10 @@ pub enum VerifyStatus {
}

impl VerifyStatus {
pub fn require_full(self) -> Result<(), RoutingError> {
pub fn require_full(self) -> Result<(), SNRoutingError> {
match self {
Self::Full => Ok(()),
Self::Unknown => Err(RoutingError::UntrustedMessage),
Self::Unknown => Err(SNRoutingError::UntrustedMessage),
}
}
}
Expand All @@ -315,7 +315,7 @@ pub(crate) struct QueuedMessage {
pub sender: Option<SocketAddr>,
}

pub fn log_verify_failure<'a, T, I>(msg: &T, error: &RoutingError, their_keys: I)
pub fn log_verify_failure<'a, T, I>(msg: &T, error: &SNRoutingError, their_keys: I)
where
T: Debug,
I: IntoIterator<Item = (&'a Prefix, &'a bls::PublicKey)>,
Expand Down Expand Up @@ -350,7 +350,7 @@ pub enum CreateError {
FailedSignature,
}

impl From<CreateError> for RoutingError {
impl From<CreateError> for SNRoutingError {
fn from(src: CreateError) -> Self {
match src {
CreateError::Bincode(inner) => Self::Bincode(inner),
Expand Down
Loading

0 comments on commit 583f7f9

Please sign in to comment.