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

MAID-1675: accumulate messages in the first hop #1213

Merged
merged 25 commits into from Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
370e682
fix/clippy: fix new clippy warning
Nov 5, 2016
6cf9312
chore/build: update dependencies
Nov 5, 2016
a118ccc
fix/utils: update calculate_relocated_name and re-enable and fix test
Nov 4, 2016
78d9e70
feat/node: accumulate messages in the first hop
Nov 3, 2016
bb98db6
fix/routing_table: workaround for routing connection info via the joi…
fizyk20 Nov 8, 2016
8ec841d
fix/routing_table: use the joining node's name for excluding groups
fizyk20 Nov 8, 2016
ae40d6f
style/all: address review comments
fizyk20 Nov 8, 2016
2bbb057
Merge branch 'master' into MAID-1698
Nov 8, 2016
959e9bd
fix/messages: address review comments
Nov 8, 2016
f1013b6
Merge branch 'new_acc' of https://github.com/afck/routing into new_acc
Nov 8, 2016
d21568a
Merge branch 'MAID-1698' of https://github.com/fizyk20/routing into n…
Nov 8, 2016
20b74da
fix/messages: address review comments
Nov 8, 2016
03a93c1
fix/routing_table: update group merge prefixes to remain consistently…
Nov 9, 2016
db15401
Merge branch 'master' into use_sorted
Nov 9, 2016
6cbe6eb
Merge branch 'master' into use_sorted
afck Nov 9, 2016
e8f78eb
Merge remote-tracking branch 'origin/use_sorted' into new_acc
Nov 9, 2016
2f635d3
chore/ci: increase Travis CI timeouts
Nov 9, 2016
2903b66
Merge branch 'use_sorted' into new_acc
Nov 9, 2016
a1ec83b
Merge branch 'master' into new_acc
Nov 9, 2016
5535faa
fix/node: address further review comments
Nov 9, 2016
243e0ee
fix/xorable: fix bug in 'Xorable::common_prefix()' for arrays
Nov 9, 2016
0d311f5
fix/signature_accumulator: fix a bug in 'SignatureAccumulator::add_me…
Nov 9, 2016
449584d
Merge branch 'master' into new_acc
Nov 10, 2016
aa9ac23
style/clippy: fix clippy warning
Nov 9, 2016
32d1941
fix/core_test: ignore an intermittently-failing test for now
Nov 11, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -11,9 +11,9 @@ repository = "https://github.com/maidsafe/routing"
version = "0.25.1"

[dependencies]
clippy = {version = "~0.0.95", optional = true}
clippy = {version = "~0.0.97", optional = true}
crust = "~0.19.0"
itertools = "~0.5.2"
itertools = "~0.5.5"
log = "~0.3.6"
lru_time_cache = "~0.5.0"
maidsafe_utilities = "~0.10.0"
Expand All @@ -26,7 +26,7 @@ unwrap = "~1.1.0"

[dev-dependencies]
docopt = "~0.6.86"
libc = "~0.2.16"
libc = "~0.2.17"

[build-dependencies]
hyper = {version = "~0.9.10", optional = true}
Expand Down
4 changes: 2 additions & 2 deletions src/ack_manager.rs
Expand Up @@ -16,7 +16,7 @@
// relating to use of the SAFE Network Software.

use error::RoutingError;
use maidsafe_utilities;
use maidsafe_utilities::{self, serialisation};
use message_filter::MessageFilter;
use messages::RoutingMessage;
use std::collections::HashMap;
Expand Down Expand Up @@ -111,7 +111,7 @@ impl AckManager {

impl Ack {
pub fn compute(routing_msg: &RoutingMessage) -> Result<Ack, RoutingError> {
let hash_msg = try!(routing_msg.to_grp_msg_hash());
let hash_msg = try!(serialisation::serialise(routing_msg));
Ok(Ack(maidsafe_utilities::big_endian_sip_hash(&hash_msg)))
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/authority.rs
Expand Up @@ -61,6 +61,15 @@ impl Authority {
}
}

/// Returns true if a client, false if a node or group.
pub fn is_client(&self) -> bool {
if let Authority::Client { .. } = *self {
true
} else {
false
}
}

Copy link
Contributor

@dhardy dhardy Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can shortcut this (silly pattern, but still shorter):

if let *self == Authority::Client { .. } { true } else { false }

You could of course do the same with match, unless an explicit match against other cases is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - I'll change to if let.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find match more readable (and easier to modify in the future if we add some other client type), but I won't argue ;)

/// Returns the name of authority.
pub fn name(&self) -> &XorName {
match *self {
Expand Down
33 changes: 22 additions & 11 deletions src/core_tests.rs
Expand Up @@ -51,7 +51,10 @@ macro_rules! expect_next_event {
match $node.event_rx.try_recv() {
Ok($pattern) => break,
Ok(Event::Tick) => (),
other => panic!("Expected Ok({}), got {:?}", stringify!($pattern), other),
other => panic!("Expected Ok({}) at {}, got {:?}",
stringify!($pattern),
unwrap!($node.inner.name()),
other),
}
}
}
Expand All @@ -69,7 +72,10 @@ macro_rules! expect_any_event {
match $node.event_rx.try_recv() {
Ok($pattern) if $guard => break,
Ok(_) => (),
other => panic!("Expected Ok({}), got {:?}", stringify!($pattern), other),
other => panic!("Expected Ok({}) at {}, got {:?}",
stringify!($pattern),
unwrap!($node.inner.name()),
other),
}
}
}
Expand All @@ -81,7 +87,9 @@ macro_rules! expect_no_event {
match $node.event_rx.try_recv() {
Ok(Event::Tick) => (),
Err(mpsc::TryRecvError::Empty) => (),
other => panic!("Expected no event, got {:?}", other),
other => panic!("Expected no event at {}, got {:?}",
unwrap!($node.inner.name()),
other),
}
}
}
Expand Down Expand Up @@ -324,7 +332,9 @@ fn create_connected_nodes_with_cache(network: &Network,
}
}

assert!(node_added_count >= n, "Got only {} NodeAdded events.");
assert!(node_added_count >= n,
"Got only {} NodeAdded events.",
node_added_count);
}

nodes
Expand Down Expand Up @@ -565,6 +575,7 @@ fn equal_group_size_nodes() {
}

#[test]
#[ignore]
fn more_than_group_size_nodes() {
test_nodes(MIN_GROUP_SIZE * 6);
}
Expand Down Expand Up @@ -908,9 +919,9 @@ fn successful_get_request() {
Ok(Event::Request { request: Request::Get(ref request, id), src, dst }) => {
request_received_count += 1;
if data_request == *request && message_id == id {
if let Err(_) = node.inner
if let Err(err) = node.inner
.send_get_success(dst, src, data.clone(), id) {
trace!("Failed to send GetSuccess response");
trace!("Failed to send GetSuccess response: {:?}", err);
}
break;
}
Expand Down Expand Up @@ -977,9 +988,9 @@ fn failed_get_request() {
Ok(Event::Request { request: Request::Get(ref data_id, ref id), src, dst }) => {
request_received_count += 1;
if data_request == *data_id && message_id == *id {
if let Err(_) = node.inner
if let Err(err) = node.inner
.send_get_failure(dst, src, *data_id, vec![], *id) {
trace!("Failed to send GetFailure response.");
trace!("Failed to send GetFailure response: {:?}", err);
}
break;
}
Expand Down Expand Up @@ -1044,9 +1055,9 @@ fn disconnect_on_get_request() {
Ok(Event::Request { request: Request::Get(ref request, ref id), src, dst }) => {
request_received_count += 1;
if data_request == *request && message_id == *id {
if let Err(_) = node.inner
if let Err(err) = node.inner
.send_get_success(dst, src, data.clone(), *id) {
trace!("Failed to send GetSuccess response");
trace!("Failed to send GetSuccess response: {:?}", err);
}
break;
}
Expand Down Expand Up @@ -1338,7 +1349,7 @@ fn response_caching() {

let message_id = MessageId::new();

// The proxy node should have cached the data, so this reqeust should only
// The proxy node should have cached the data, so this request should only
// hit the proxy node and not be relayed to the other nodes.
unwrap!(clients[0].inner.send_get_request(dst, data_id, message_id));

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -156,6 +156,7 @@ mod node;
mod peer_manager;
mod routing_message_filter;
mod routing_table;
mod signature_accumulator;
mod state_machine;
mod states;
mod stats;
Expand Down