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

Commit

Permalink
Rename Bootstrapping to BootstrappingPeer
Browse files Browse the repository at this point in the history
So all state names are nouns now, for consistency.
  • Loading branch information
madadam committed May 8, 2019
1 parent 4c14e01 commit af1831f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::messages::{Request, CLIENT_GET_PRIORITY, DEFAULT_PRIORITY};
use crate::outbox::{EventBox, EventBuf};
use crate::routing_table::Authority;
use crate::state_machine::{State, StateMachine};
use crate::states::{Bootstrapping, BootstrappingTargetState};
use crate::states::{BootstrappingPeer, TargetState};
use crate::types::{MessageId, RoutingActionSender};
use crate::xor_name::XorName;
use crate::{BootstrapConfig, MIN_SECTION_SIZE};
Expand Down Expand Up @@ -72,16 +72,16 @@ impl Client {

StateMachine::new(
move |action_sender, crust_service, timer, _outbox2| {
Bootstrapping::new(
BootstrappingPeer::new(
action_sender,
Box::new(NullCache),
BootstrappingTargetState::Client { msg_expiry_dur },
TargetState::Client { msg_expiry_dur },
crust_service,
full_id,
min_section_size,
timer,
)
.map_or(State::Terminated, State::Bootstrapping)
.map_or(State::Terminated, State::BootstrappingPeer)
},
pub_id,
bootstrap_config,
Expand Down
8 changes: 4 additions & 4 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::messages::{
use crate::outbox::{EventBox, EventBuf};
use crate::routing_table::Authority;
use crate::state_machine::{State, StateMachine};
use crate::states::{self, Bootstrapping, BootstrappingTargetState};
use crate::states::{self, BootstrappingPeer, TargetState};
use crate::types::{MessageId, RoutingActionSender};
use crate::xor_name::XorName;
#[cfg(feature = "mock_base")]
Expand Down Expand Up @@ -159,16 +159,16 @@ impl NodeBuilder {
outbox2.send_event(Event::Terminated);
State::Terminated
} else {
Bootstrapping::new(
BootstrappingPeer::new(
action_sender,
self.cache,
BootstrappingTargetState::RelocatingNode,
TargetState::RelocatingNode,
crust_service,
full_id,
min_section_size,
timer,
)
.map_or(State::Terminated, State::Bootstrapping)
.map_or(State::Terminated, State::BootstrappingPeer)
}
},
pub_id,
Expand Down
18 changes: 9 additions & 9 deletions src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
outbox::EventBox,
routing_table::Prefix,
states::common::Base,
states::{Bootstrapping, Client, EstablishingNode, Node, ProvingNode, RelocatingNode},
states::{BootstrappingPeer, Client, EstablishingNode, Node, ProvingNode, RelocatingNode},
timer::Timer,
types::RoutingActionSender,
xor_name::XorName,
Expand All @@ -37,7 +37,7 @@ use std::{
macro_rules! state_dispatch {
($self:expr, $state:pat => $expr:expr, Terminated => $term_expr:expr) => {
match $self {
State::Bootstrapping($state) => $expr,
State::BootstrappingPeer($state) => $expr,
State::Client($state) => $expr,
State::RelocatingNode($state) => $expr,
State::ProvingNode($state) => $expr,
Expand All @@ -64,7 +64,7 @@ pub struct StateMachine {
// FIXME - See https://maidsafe.atlassian.net/browse/MAID-2026 for info on removing this exclusion.
#[allow(clippy::large_enum_variant)]
pub enum State {
Bootstrapping(Bootstrapping),
BootstrappingPeer(BootstrappingPeer),
Client(Client),
RelocatingNode(RelocatingNode),
ProvingNode(ProvingNode),
Expand Down Expand Up @@ -127,7 +127,7 @@ impl State {
match *self {
State::EstablishingNode(ref state) => Some(state.chain()),
State::Node(ref state) => Some(state.chain()),
State::Bootstrapping(_)
State::BootstrappingPeer(_)
| State::Client(_)
| State::RelocatingNode(_)
| State::ProvingNode(_)
Expand Down Expand Up @@ -200,7 +200,7 @@ impl State {

pub fn get_timed_out_tokens(&mut self) -> Vec<u64> {
match *self {
State::Bootstrapping(_) | State::Terminated => vec![],
State::BootstrappingPeer(_) | State::Terminated => vec![],
State::Client(ref mut state) => state.get_timed_out_tokens(),
State::RelocatingNode(ref mut state) => state.get_timed_out_tokens(),
State::ProvingNode(ref mut state) => state.get_timed_out_tokens(),
Expand All @@ -220,7 +220,7 @@ impl State {
pub fn has_unpolled_observations(&self, filter_opaque: bool) -> bool {
match *self {
State::Terminated
| State::Bootstrapping(_)
| State::BootstrappingPeer(_)
| State::Client(_)
| State::RelocatingNode(_)
| State::ProvingNode(_) => false,
Expand All @@ -239,7 +239,7 @@ impl State {

pub fn in_authority(&self, auth: &Authority<XorName>) -> bool {
match *self {
State::Terminated | State::Bootstrapping(_) => false,
State::Terminated | State::BootstrappingPeer(_) => false,
State::Client(ref state) => state.in_authority(auth),
State::RelocatingNode(ref state) => state.in_authority(auth),
State::ProvingNode(ref state) => state.in_authority(auth),
Expand All @@ -250,7 +250,7 @@ impl State {

pub fn has_unacked_msg(&self) -> bool {
match *self {
State::Terminated | State::Bootstrapping(_) => false,
State::Terminated | State::BootstrappingPeer(_) => false,
State::Client(ref state) => state.ack_mgr().has_unacked_msg(),
State::RelocatingNode(ref state) => state.ack_mgr().has_unacked_msg(),
State::ProvingNode(ref state) => state.ack_mgr().has_unacked_msg(),
Expand Down Expand Up @@ -409,7 +409,7 @@ impl StateMachine {
match transition {
Stay => (),
IntoBootstrapped { proxy_public_id } => self.state.replace_with(|state| match state {
State::Bootstrapping(src) => src.into_target_state(proxy_public_id, outbox),
State::BootstrappingPeer(src) => src.into_target_state(proxy_public_id, outbox),
_ => unreachable!(),
}),
IntoBootstrapping {
Expand Down
20 changes: 10 additions & 10 deletions src/states/bootstrapping.rs → src/states/bootstrapping_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub enum TargetState {
}

// State of Client or Node while bootstrapping.
pub struct Bootstrapping {
pub struct BootstrappingPeer {
action_sender: RoutingActionSender,
bootstrap_blacklist: HashSet<SocketAddr>,
bootstrap_connection: Option<(PublicId, u64)>,
Expand All @@ -65,7 +65,7 @@ pub struct Bootstrapping {
timer: Timer,
}

impl Bootstrapping {
impl BootstrappingPeer {
pub fn new(
action_sender: RoutingActionSender,
cache: Box<Cache>,
Expand All @@ -86,7 +86,7 @@ impl Bootstrapping {
}
}
}
Some(Bootstrapping {
Some(Self {
action_sender,
cache: cache,
crust_service,
Expand Down Expand Up @@ -208,7 +208,7 @@ impl Bootstrapping {
}
}

impl Base for Bootstrapping {
impl Base for BootstrappingPeer {
fn crust_service(&self) -> &Service {
&self.crust_service
}
Expand Down Expand Up @@ -366,9 +366,9 @@ impl Base for Bootstrapping {
}
}

impl Display for Bootstrapping {
impl Display for BootstrappingPeer {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
write!(formatter, "Bootstrapping({})", self.name())
write!(formatter, "BootstrappingPeer({})", self.name())
}
}

Expand Down Expand Up @@ -423,7 +423,7 @@ mod tests {
let pub_id = *full_id.public_id();
StateMachine::new(
move |action_sender, crust_service, timer, _outbox2| {
Bootstrapping::new(
BootstrappingPeer::new(
action_sender,
Box::new(NullCache),
TargetState::Client {
Expand All @@ -434,7 +434,7 @@ mod tests {
min_section_size,
timer,
)
.map_or(State::Terminated, State::Bootstrapping)
.map_or(State::Terminated, State::BootstrappingPeer)
},
pub_id,
Some(config),
Expand All @@ -455,14 +455,14 @@ mod tests {
// caused it to send a `BootstrapRequest` and add the Crust service to its
// `bootstrap_blacklist`.
match *state_machine.current() {
State::Bootstrapping(ref state) => assert!(state.bootstrap_blacklist.is_empty()),
State::BootstrappingPeer(ref state) => assert!(state.bootstrap_blacklist.is_empty()),
_ => panic!("Should be in `Bootstrapping` state."),
}
network.deliver_messages();
unwrap!(state_machine.step(&mut outbox));
assert!(outbox.take_all().is_empty());
match *state_machine.current() {
State::Bootstrapping(ref state) => assert_eq!(state.bootstrap_blacklist.len(), 1),
State::BootstrappingPeer(ref state) => assert_eq!(state.bootstrap_blacklist.len(), 1),
_ => panic!("Should be in `Bootstrapping` state."),
}

Expand Down
4 changes: 2 additions & 2 deletions src/states/mod.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.

mod bootstrapping;
mod bootstrapping_peer;
mod client;
pub mod common;
mod establishing_node;
Expand All @@ -15,7 +15,7 @@ mod proving_node;
mod relocating_node;

pub use self::{
bootstrapping::{Bootstrapping, TargetState as BootstrappingTargetState},
bootstrapping_peer::{BootstrappingPeer, TargetState},
client::{Client, RATE_EXCEED_RETRY},
establishing_node::EstablishingNode,
node::Node,
Expand Down
8 changes: 4 additions & 4 deletions src/states/relocating_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use super::{
common::{proxied, Base, Bootstrapped, BootstrappedNotEstablished},
Bootstrapping, BootstrappingTargetState,
BootstrappingPeer, TargetState,
};
use crate::{
ack_manager::{Ack, AckManager},
Expand Down Expand Up @@ -104,11 +104,11 @@ impl RelocatingNode {
crust_rx,
crust_sender,
);
let target_state = BootstrappingTargetState::ProvingNode {
let target_state = TargetState::ProvingNode {
old_full_id: self.full_id,
our_section: our_section,
};
if let Some(bootstrapping) = Bootstrapping::new(
if let Some(peer) = BootstrappingPeer::new(
self.action_sender,
self.cache,
target_state,
Expand All @@ -117,7 +117,7 @@ impl RelocatingNode {
self.min_section_size,
self.timer,
) {
State::Bootstrapping(bootstrapping)
State::BootstrappingPeer(peer)
} else {
outbox.send_event(Event::RestartRequired);
State::Terminated
Expand Down

0 comments on commit af1831f

Please sign in to comment.