Skip to content
This repository was archived by the owner on Jan 6, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
3b8e07e
FakeVaultFacade WIP.
Feb 27, 2015
c20c89e
Restoring routing node and connection manager to old state along with…
chandraprakash Mar 1, 2015
fb51547
updated comments
chandraprakash Mar 2, 2015
db79752
style fixes
chandraprakash Mar 2, 2015
a695457
Brings the Connections class into this branch
inetic Mar 2, 2015
b5cbd05
First sketch of crux->routing integration
inetic Mar 2, 2015
59cd68f
Renames few functions
inetic Mar 3, 2015
26df0b7
Sketch of how receiving works with crux
inetic Mar 3, 2015
e80c775
Removes the io_service& argument from ConnectionManagers constructor
inetic Mar 3, 2015
8b40e95
ConnectionManager::{AddNode,AddNodeAccept} pass group difference ot i…
inetic Mar 3, 2015
167d896
RoutingNode now starts listening right after construction
inetic Mar 3, 2015
4e9a9b1
Connections class exchanges endpoints on connection establishment
inetic Mar 4, 2015
01c057d
Info about our endpoint is propagated up to the RoutingNode
inetic Mar 4, 2015
2930ef1
Merge remote-tracking branch 'mahmoud/MAID-836' into MAID-843-integra…
inetic Mar 4, 2015
0a2ff88
Replaces the dummy send function with a proper one
inetic Mar 4, 2015
eac48ce
RoutingNode starts bootstrap in its constructor
inetic Mar 4, 2015
66b4918
Fixes compilation
inetic Mar 4, 2015
a5f3eee
Fixes invalid resialisation of the ConnectResponse message
inetic Mar 4, 2015
fcdbceb
Fixes invalid serialisation of the Connect message
inetic Mar 4, 2015
3f28b56
Put/Get message handling and further testing.
Mar 4, 2015
e013f5d
Minor change.
Mar 6, 2015
6e675bd
minor updates
chandraprakash Mar 6, 2015
8514a51
moved connected nodes to connection manager.
chandraprakash Mar 9, 2015
a68de33
minor update
chandraprakash Mar 9, 2015
5ef3f97
Connections class now supports asio::async_result
inetic Mar 9, 2015
1e6d5c1
Merge remote-tracking branch 'prakash/inetic-MAID-843-integration-wit…
inetic Mar 10, 2015
2501135
Fixes a compilation problem
inetic Mar 11, 2015
567b28e
Refactores acceptation of new connections
inetic Mar 11, 2015
bc02338
NextEndpointPair now returns an endpoint we're accepting on
inetic Mar 12, 2015
4ea6da7
Propagate connection lost information up from ConnectionManager
inetic Mar 12, 2015
eed5bbc
temp code.
chandraprakash Mar 12, 2015
1c8b956
Connections class now owns its BoostIoService
inetic Mar 12, 2015
38c73bc
This should fix the RoutingNode::NextEndpointPair implementation
inetic Mar 12, 2015
263b530
Merge branch 'MAID-843-integration-with-crux' of https://github.com/i…
chandraprakash Mar 13, 2015
9e0bb73
Merge pull request #1 from BSMaidSafe/MAID-838
chandraprakash Mar 13, 2015
3720268
debugging zero state
chandraprakash Mar 13, 2015
e4aaf47
Merge branch 'next' into inetic-MAID-843-integration-with-crux
chandraprakash Mar 15, 2015
73b48a5
fixes for RelayedMessage.
chandraprakash Mar 16, 2015
5c7b3b5
some debugging logs
chandraprakash Mar 16, 2015
167d5f9
backup
inetic Mar 16, 2015
fde688a
minor cleanup (doesn't compile)
chandraprakash Mar 16, 2015
febb794
backup
inetic Mar 17, 2015
33e5153
Removes some debug output
inetic Mar 17, 2015
ab652d3
Restores the previous ApplyTuple function
inetic Mar 17, 2015
c2be91c
Changed signature of Put() method. Also sending it to client manager …
chandraprakash Mar 17, 2015
6725680
Ditch the AsyncQueue
inetic Mar 17, 2015
fa6f143
Merge branch 'next' into inetic-MAID-843-integration-with-crux
chandraprakash Mar 17, 2015
a3a60c8
Merge branch 'MAID-843-integration-with-crux' of https://github.com/i…
chandraprakash Mar 17, 2015
78b8f95
Fixes (private) Connections::post function
inetic Mar 17, 2015
d17eaff
Adds non-boost::asio::work to the Connections class
inetic Mar 17, 2015
a9978ed
Merge branch 'MAID-843-integration-with-crux' of https://github.com/i…
chandraprakash Mar 18, 2015
0bf952e
Merge branch 'MAID-843-integration-with-crux' of https://github.com/i…
chandraprakash Mar 18, 2015
306ae70
sending connect to bootstrap_node if RT is empty.
chandraprakash Mar 18, 2015
187676f
Merge remote-tracking branch 'prakash/inetic-MAID-843-integration-wit…
Fraser999 Mar 18, 2015
21b9a7f
Merge branch 'inetic-MAID-843-integration-with-crux' of github.com:ch…
Fraser999 Mar 18, 2015
3f609f6
Trivial fixes.
Fraser999 Mar 18, 2015
525fbe6
Testing Put (WIP).
Fraser999 Mar 18, 2015
037d91b
added utility function to SendSwarmOrParallel or SendToBootstrapNode
chandraprakash Mar 18, 2015
5fc10fa
Compilation fixes
inetic Mar 18, 2015
12124f7
further cleanup
chandraprakash Mar 19, 2015
7680e4d
temp code
chandraprakash Mar 19, 2015
9c574f8
Merge remote-tracking branch 'prakash/inetic-MAID-843-integration-wit…
Fraser999 Mar 19, 2015
85a9f4b
Merge branch 'MAID-843-integration-with-crux' of https://github.com/i…
chandraprakash Mar 19, 2015
b8a5c97
AddNode handler arguments now contain an error_code
inetic Mar 20, 2015
5dc46df
Node is added into routing table even if connect timed out
inetic Mar 20, 2015
707c842
Merge remote-tracking branch 'inetic/MAID-843-integration-with-crux' …
Fraser999 Mar 20, 2015
7d091da
Ran clang-format.
Fraser999 Mar 20, 2015
80bc1a2
Changed to use shared_ptr to base data type.
Fraser999 Mar 20, 2015
77a40df
wip on relay
chandraprakash Mar 20, 2015
af96244
Merge branch 'inetic-MAID-843-integration-with-crux' of https://githu…
chandraprakash Mar 23, 2015
98d47a1
Merge branch 'next' into inetic-MAID-843-integration-with-crux
chandraprakash Mar 23, 2015
9816219
minor fix
chandraprakash Mar 23, 2015
d29e533
Merge remote-tracking branch 'upstream/next' into inetic-MAID-843-int…
Fraser999 Mar 23, 2015
cb03a28
Bugfix for IPv4/v6 handling in Connections.
Fraser999 Mar 23, 2015
122f4dd
Missed file in merge.
Fraser999 Mar 23, 2015
9fb6d3c
Renamed HandlePutPostReturn to HandlePutReturn.
Fraser999 Mar 23, 2015
76db82b
minor updates
chandraprakash Mar 23, 2015
a0650f1
Merge remote-tracking branch 'upstream/next' into inetic-MAID-843-int…
Fraser999 Mar 24, 2015
313272d
Merge remote-tracking branch 'prakash/inetic-MAID-843-integration-wit…
Fraser999 Mar 24, 2015
4e7ea96
Revert "Renamed HandlePutPostReturn to HandlePutReturn."
Fraser999 Mar 24, 2015
af3b1fb
"Fix" vault facade test.
Fraser999 Mar 24, 2015
357e0a6
Merge branch 'inetic-MAID-843-integration-with-crux' of https://githu…
chandraprakash Mar 24, 2015
20c2c49
Style fixes.
Fraser999 Mar 24, 2015
da9a19e
Message to ostream serialization for easier debugging
inetic Mar 24, 2015
5620e55
Merge remote-tracking branch 'fraser/inetic-MAID-843-integration-with…
inetic Mar 24, 2015
9549662
RoutingFakeVaultFacade test now passes.
inetic Mar 24, 2015
58e9e29
Removes std::cerr debug output
inetic Mar 24, 2015
df4dc14
wip
chandraprakash Mar 24, 2015
049fcde
Merge branch 'MAID-843-integration-with-crux' of https://github.com/i…
chandraprakash Mar 24, 2015
86691d5
minor update and fix from peter
chandraprakash Mar 24, 2015
7d38d75
Connections class to report already_connected error
inetic Mar 25, 2015
1dc9f24
Merge branch 'inetic-MAID-843-integration-with-crux' of github.com:ch…
inetic Mar 25, 2015
43886dc
added log
chandraprakash Mar 25, 2015
4685655
wip on relay logic
chandraprakash Mar 25, 2015
0866857
added debug code
chandraprakash Mar 26, 2015
a514a93
Debug output
inetic Mar 26, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
578 changes: 371 additions & 207 deletions include/maidsafe/routing/routing_node.h

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions include/maidsafe/routing/source_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ inline bool operator>=(const SourceAddress& lhs, const SourceAddress& rhs) {
return !operator<(lhs, rhs);
}

inline std::ostream& operator<<(std::ostream& os, const SourceAddress& addr) {
os << "(SourceAddress node:" << reinterpret_cast<const Address&>(addr.node_address) << ", ";
if (addr.group_address) {
os << "group:" << reinterpret_cast<const Address&>(*addr.group_address);
}
else {
os << "group:none";
}
if (addr.reply_to_address) {
os << ", reply_to:" << reinterpret_cast<const Address&>(*addr.reply_to_address);
}
else {
os << ", reply_to:none";
}
return os << ")";
}

} // namespace routing

} // namespace maidsafe
Expand Down
20 changes: 14 additions & 6 deletions include/maidsafe/routing/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace routing {
static const size_t GroupSize = 23;
static const size_t QuorumSize = 19;

enum class FromType : int32_t {
enum class FromType : std::int32_t {
client_manager,
nae_manager,
node_manager,
Expand All @@ -58,7 +58,7 @@ enum class FromType : int32_t {
node
};

enum class Authority : int32_t {
enum class Authority : std::int32_t {
client_manager,
nae_manager,
node_manager,
Expand All @@ -68,7 +68,7 @@ enum class Authority : int32_t {
};

using Address = Identity;
using MessageId = uint32_t;
using MessageId = std::uint32_t;
using Destination = TaggedValue<Address, struct DestinationTag>;
using ReplyToAddress = TaggedValue<Address, struct ReplytoTag>;
using DestinationAddress = std::pair<Destination, boost::optional<ReplyToAddress>>;
Expand All @@ -89,15 +89,23 @@ using HandleGetReturn =
maidsafe_error>;
using HandlePutPostReturn = boost::expected<std::vector<DestinationAddress>, maidsafe_error>;
using HandlePostReturn =
boost::expected<std::pair<std::vector<DestinationAddress>, std::vector<byte>>,
maidsafe_error>;
boost::expected<std::pair<std::vector<DestinationAddress>, std::vector<byte>>, maidsafe_error>;

using Endpoint = asio::ip::udp::endpoint;
using Port = uint16_t;
using Port = std::uint16_t;
using SerialisedMessage = std::vector<byte>;
using CloseGroupDifference = std::pair<std::vector<Address>, std::vector<Address>>;
using PublicKeyId = std::pair<Address, asymm::PublicKey>;

template <typename CompletionToken, typename... Args>
using AsyncResultHandler = typename asio::handler_type<typename std::decay<CompletionToken>::type,
void(asio::error_code, Args...)>::type;

template <typename CompletionToken, typename... Args>
using AsyncResultReturn =
typename asio::async_result<AsyncResultHandler<CompletionToken, Args...>>::type;

// FIXME: All the below handlers and results can be implemented using the above two.
template <typename CompletionToken>
using BootstrapHandlerHandler =
typename asio::handler_type<CompletionToken, void(asio::error_code, Contact)>::type;
Expand Down
59 changes: 59 additions & 0 deletions src/maidsafe/routing/apply_tuple.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Copyright 2015 MaidSafe.net limited

This MaidSafe Software is licensed to you under (1) the MaidSafe.net Commercial License,
version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
licence you accepted on initial access to the Software (the "Licences").

By contributing code to the MaidSafe Software, or to this project generally, you agree to be
bound by the terms of the MaidSafe Contributor Agreement, version 1.0, found in the root
directory of this project at LICENSE, COPYING and CONTRIBUTOR respectively and also
available at: http://www.maidsafe.net/licenses

Unless required by applicable law or agreed to in writing, the MaidSafe Software distributed
under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied.

See the Licences for the specific language governing permissions and limitations relating to
use of the MaidSafe Software. */

#ifndef MAIDSAFE_ROUTING_APPLY_TUPLE_H_
#define MAIDSAFE_ROUTING_APPLY_TUPLE_H_

#include <tuple>

namespace maidsafe {

namespace routing {

namespace helper {

template <int... Is>
struct Index {};

template <int N, int... Is>
struct GeneratedSequence : GeneratedSequence<N - 1, N - 1, Is...> {};

template <int... Is>
struct GeneratedSequence<0, Is...> : Index<Is...> {};

template <class F, typename... Args, int... Is>
inline MAIDSAFE_CONSTEXPR auto ApplyTuple(F&& f, const std::tuple<Args...>& tup,
helper::Index<Is...>)
-> decltype(f(std::get<Is>(tup)...)) {
return f(std::get<Is>(tup)...);
}

} // namespace helper

template <class F, typename... Args>
inline MAIDSAFE_CONSTEXPR auto ApplyTuple(F&& f, const std::tuple<Args...>& tup)
-> decltype(helper::ApplyTuple(std::forward<F>(f), tup,
helper::GeneratedSequence<sizeof...(Args)>{})) {
return helper::ApplyTuple(std::forward<F>(f), tup, helper::GeneratedSequence<sizeof...(Args)>{});
}

} // namespace routing

} // namespace maidsafe

#endif // MAIDSAFE_ROUTING_APPLY_TUPLE_H_
4 changes: 2 additions & 2 deletions src/maidsafe/routing/async_exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void AsyncExchange(crux::socket& socket, SerialisedMessage our_data, Handler han
state->tx_buffer = std::move(our_data);

socket.async_send(boost::asio::buffer(state->tx_buffer),
[state, handler](boost::system::error_code error, std::size_t) {
[state, handler](boost::system::error_code error, std::size_t) mutable {
if (state->first_error) {
if (*state->first_error) {
return handler(*state->first_error, SerialisedMessage());
Expand All @@ -61,7 +61,7 @@ void AsyncExchange(crux::socket& socket, SerialisedMessage our_data, Handler han
});

socket.async_receive(boost::asio::buffer(state->rx_buffer),
[state, handler](boost::system::error_code error, std::size_t size) {
[state, handler](boost::system::error_code error, std::size_t size) mutable {
if (state->first_error) {
if (*state->first_error) {
return handler(*state->first_error, SerialisedMessage());
Expand Down
33 changes: 2 additions & 31 deletions src/maidsafe/routing/async_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,12 @@
#include "asio/async_result.hpp"

#include "maidsafe/common/config.h"
#include "maidsafe/routing/apply_tuple.h"

namespace maidsafe {

namespace routing {

namespace detail {

namespace helper {

template <int... Is>
struct Index {};

template <int N, int... Is>
struct GeneratedSequence : GeneratedSequence<N - 1, N - 1, Is...> {};

template <int... Is>
struct GeneratedSequence<0, Is...> : Index<Is...> {};

} // namespace helper

template <class F, typename... Args, int... Is>
inline MAIDSAFE_CONSTEXPR auto ApplyTuple(F&& f, const std::tuple<Args...>& tup,
helper::Index<Is...>)
-> decltype(f(std::get<Is>(tup)...)) {
return f(std::get<Is>(tup)...);
}

template <class F, typename... Args>
inline MAIDSAFE_CONSTEXPR auto ApplyTuple(F&& f, const std::tuple<Args...>& tup)
-> decltype(ApplyTuple(f, tup, helper::GeneratedSequence<sizeof...(Args)>{})) {
return ApplyTuple(std::forward<F>(f), tup, helper::GeneratedSequence<sizeof...(Args)>{});
}

} // namespace detail

template <class... Args>
class AsyncQueue {
private:
Expand Down Expand Up @@ -111,7 +82,7 @@ class AsyncQueue {
values.pop();
}

detail::ApplyTuple(std::move(handler), tuple);
detail::ApplyTuple(handler, std::move(tuple));

return result.get();
}
Expand Down
Loading