Skip to content

Commit 26a2bd7

Browse files
Adapted to routing change.
1 parent 115ec10 commit 26a2bd7

File tree

9 files changed

+40
-45
lines changed

9 files changed

+40
-45
lines changed

include/maidsafe/detail/session_getter.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@
3636

3737
namespace maidsafe {
3838

39-
//typedef std::vector<std::pair<boost::asio::ip::udp::endpoint, asymm::PublicKey>> BootstrapInfo;
40-
4139
namespace detail {
4240

4341
class SessionGetter {
4442
public:
45-
explicit SessionGetter(const BootstrapContacts& bootstrap_contacts);
43+
explicit SessionGetter(const routing::BootstrapContacts& bootstrap_contacts);
4644
nfs_client::DataGetter& data_getter() { return *data_getter_; }
4745

4846
private:
49-
void InitRouting(const BootstrapInfo& bootstrap_info);
47+
void InitRouting(const routing::BootstrapContacts &bootstrap_contacts);
5048
routing::Functors InitialiseRoutingCallbacks();
5149
void OnNetworkStatusChange(int updated_network_health);
5250

include/maidsafe/session_handler.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SessionHandler {
6161
public:
6262
// This constructor should be used before logging in to an existing account, i.e. where the
6363
// session has not yet been retrieved from the network. Throws std::exception on error.
64-
explicit SessionHandler(const BootstrapInfo& bootstrap_info);
64+
explicit SessionHandler(const routing::BootstrapContacts& bootstrap_contacts);
6565

6666
// This constructor should be used when creating a new account, i.e. where a session has never
6767
// been put to the network. 'client' should already be joined to the network. Internally saves
@@ -124,10 +124,10 @@ Session DecryptSession(const authentication::UserCredentials& user_credentials,
124124
} // namespace detail
125125

126126
template <typename Session>
127-
SessionHandler<Session>::SessionHandler(const BootstrapInfo& bootstrap_info)
127+
SessionHandler<Session>::SessionHandler(const routing::BootstrapContacts& bootstrap_contacts)
128128
: session_(),
129129
current_session_version_(),
130-
session_getter_(maidsafe::make_unique<detail::SessionGetter>(bootstrap_info)),
130+
session_getter_(maidsafe::make_unique<detail::SessionGetter>(bootstrap_contacts)),
131131
user_credentials_() {}
132132

133133
template <typename Session>

src/maidsafe/client.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ namespace maidsafe {
2424
Client::Client(const passport::Maid& maid, const routing::BootstrapContacts& bootstrap_contacts)
2525
: pimpl_(new detail::ClientImpl(maid, bootstrap_contacts)) {}
2626

27-
Client::Client(const passport::MaidAndSigner& maid_and_signer, const BootstrapInfo& bootstrap_info)
28-
: pimpl_(new detail::ClientImpl(maid_and_signer, bootstrap_info)) {}
27+
Client::Client(const passport::MaidAndSigner& maid_and_signer,
28+
const routing::BootstrapContacts& bootstrap_contacts)
29+
: pimpl_(new detail::ClientImpl(maid_and_signer, bootstrap_contacts)) {}
2930

3031
Client::~Client() {}
3132

src/maidsafe/detail/client_impl.cc

+7-12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ namespace maidsafe {
2828

2929
namespace detail {
3030

31-
ClientImpl::ClientImpl(const passport::Maid& maid, const BootstrapInfo& bootstrap_info)
31+
ClientImpl::ClientImpl(const passport::Maid& maid,
32+
const routing::BootstrapContacts& bootstrap_contacts)
3233
: network_health_mutex_(),
3334
network_health_condition_variable_(),
3435
network_health_(-1),
@@ -41,13 +42,12 @@ ClientImpl::ClientImpl(const passport::Maid& maid, const BootstrapInfo& bootstra
4142
passport::PublicPmid::Name pmid_name; // FIXME
4243
maid_node_nfs_ =
4344
maidsafe::make_unique<nfs_client::MaidNodeNfs>(asio_service_, routing_, pmid_name);
44-
// FIXME need to update routing to get bootstrap endpoints along with public keys
45-
InitRouting(bootstrap_info);
45+
InitRouting(bootstrap_contacts);
4646
LOG(kInfo) << "Routing Initialised";
4747
}
4848

4949
ClientImpl::ClientImpl(const passport::MaidAndSigner& maid_and_signer,
50-
const BootstrapInfo& bootstrap_info)
50+
const routing::BootstrapContacts& bootstrap_contacts)
5151
: network_health_mutex_(),
5252
network_health_condition_variable_(),
5353
network_health_(-1),
@@ -60,8 +60,7 @@ ClientImpl::ClientImpl(const passport::MaidAndSigner& maid_and_signer,
6060
passport::PublicPmid::Name pmid_name; // FIXME to be filled in by vault registration
6161
maid_node_nfs_ =
6262
maidsafe::make_unique<nfs_client::MaidNodeNfs>(asio_service_, routing_, pmid_name);
63-
// FIXME need to update routing to get bootstrap endpoints along with public keys
64-
InitRouting(bootstrap_info);
63+
InitRouting(bootstrap_contacts);
6564
LOG(kInfo) << "Routing Initialised";
6665
passport::PublicMaid public_maid{ maid_ };
6766
passport::PublicAnmaid public_anmaid{ maid_and_signer.second };
@@ -134,13 +133,9 @@ void ClientImpl::DeleteBranchUntilFork(const MutableData::Name& mutable_data_nam
134133
return maid_node_nfs_->DeleteBranchUntilFork(mutable_data_name, branch_tip);
135134
}
136135

137-
void ClientImpl::InitRouting(const BootstrapInfo& bootstrap_info) {
136+
void ClientImpl::InitRouting(const routing::BootstrapContacts& bootstrap_contacts) {
138137
routing::Functors functors(InitialiseRoutingCallbacks());
139-
// BEFORE_RELEASE temp work around, need to update routing to take bootstrap_info
140-
std::vector<boost::asio::ip::udp::endpoint> peer_endpoints;
141-
for (const auto& i : bootstrap_info)
142-
peer_endpoints.push_back(i.first);
143-
routing_.Join(functors, peer_endpoints);
138+
routing_.Join(functors, bootstrap_contacts);
144139
std::unique_lock<std::mutex> lock(network_health_mutex_);
145140
// FIXME BEFORE_RELEASE discuss this
146141
// This should behave differently. In case of new maid account, it should timeout

src/maidsafe/detail/client_impl.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ namespace detail {
4747

4848
class ClientImpl {
4949
public:
50-
ClientImpl(const passport::Maid& maid, const BootstrapInfo& bootstrap_info);
50+
ClientImpl(const passport::Maid& maid, const routing::BootstrapContacts& bootstrap_contacts);
5151

52-
ClientImpl(const passport::MaidAndSigner& maid_and_signer, const BootstrapInfo& bootstrap_info);
52+
ClientImpl(const passport::MaidAndSigner& maid_and_signer,
53+
const routing::BootstrapContacts& bootstrap_contacts);
5354

5455
Client::RegisterVaultFuture RegisterVault(const passport::Pmid& pmid,
5556
const std::chrono::steady_clock::duration& timeout);
@@ -88,7 +89,7 @@ class ClientImpl {
8889
friend class test::ClientTest_FUNC_RegisterVault_Test;
8990

9091
private:
91-
void InitRouting(const BootstrapInfo& bootstrap_info);
92+
void InitRouting(const routing::BootstrapContacts& bootstrap_contacts);
9293
routing::Functors InitialiseRoutingCallbacks();
9394
void OnNetworkStatusChange(int network_health);
9495
void DoOnNetworkStatusChange(int network_health);

src/maidsafe/detail/session_getter.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ routing::Functors SessionGetter::InitialiseRoutingCallbacks() {
7979
[this](const routing::GroupToSingleMessage& /*message*/) {};
8080
functors.typed_message_and_caching.group_to_group.put_cache_data =
8181
[this](const routing::GroupToGroupMessage& /*message*/) {};
82-
functors.new_bootstrap_endpoint =
83-
[this](const boost::asio::ip::udp::endpoint& /*endpoint*/) {};
82+
functors.new_bootstrap_contact =
83+
[this](const routing::BootstrapContact& /*bootstrap_contact*/) {};
8484

8585
return functors;
8686
}

src/maidsafe/tests/client_test.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ namespace bp = boost::process;
3838
// Pre-condition : Need a Vault network running
3939
TEST(ClientTest, FUNC_Constructor) {
4040
routing::Parameters::append_local_live_port_endpoint = true;
41-
BootstrapInfo bootstrap_info;
41+
routing::BootstrapContacts bootstrap_contacts;
4242
auto maid_and_signer(passport::CreateMaidAndSigner());
4343
{
44-
Client client_new_account(maid_and_signer, bootstrap_info);
44+
Client client_new_account(maid_and_signer, bootstrap_contacts);
4545
}
4646
LOG(kInfo) << "joining existing account";
47-
Client client_existing_account(maid_and_signer.first, bootstrap_info);
47+
Client client_existing_account(maid_and_signer.first, bootstrap_contacts);
4848
}
4949

5050
TEST(ClientTest, FUNC_RegisterVault) {
5151
routing::Parameters::append_local_live_port_endpoint = true;
52-
BootstrapInfo bootstrap_info;
52+
routing::BootstrapContacts bootstrap_contacts;
5353
auto maid_and_signer(passport::CreateMaidAndSigner());
5454
{
55-
Client client_new_account(maid_and_signer, bootstrap_info);
55+
Client client_new_account(maid_and_signer, bootstrap_contacts);
5656
}
5757
std::cout << "joining existing account" << std::endl;
58-
Client client_existing_account(maid_and_signer.first, bootstrap_info);
58+
Client client_existing_account(maid_and_signer.first, bootstrap_contacts);
5959
passport::Anpmid anpmid;
6060
passport::Pmid pmid(anpmid);
6161
passport::PublicPmid public_pmid(pmid);

src/maidsafe/tests/session_getter_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace test {
3232

3333
TEST(SessionGetterTest, FUNC_Constructor) {
3434
routing::Parameters::append_local_live_port_endpoint = true;
35-
BootstrapInfo bootstrap_info;
35+
routing::BootstrapContacts bootstrap_contacts;
3636
{
37-
SessionGetter session_getter(bootstrap_info);
37+
SessionGetter session_getter(bootstrap_contacts);
3838
}
3939
}
4040

src/maidsafe/tests/session_handler_test.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ struct TestSession {
4949
// Pre-condition : Need a Vault network running
5050
TEST(SessionHandlerTest, FUNC_Constructor) {
5151
routing::Parameters::append_local_live_port_endpoint = true;
52-
BootstrapInfo bootstrap_info;
52+
routing::BootstrapContacts bootstrap_contacts;
5353
LOG(kInfo) << "Session Handler for exisiting account";
5454
{
55-
SessionHandler<AnonymousSession> session_handler(bootstrap_info);
55+
SessionHandler<AnonymousSession> session_handler(bootstrap_contacts);
5656
}
5757

5858
LOG(kInfo) << "Session Handler for new account";
5959
{
6060
auto maid_and_signer(passport::CreateMaidAndSigner());
61-
Client client(maid_and_signer, bootstrap_info);
61+
Client client(maid_and_signer, bootstrap_contacts);
6262
AnonymousSession session(maid_and_signer);
6363
authentication::UserCredentials user_credentials(GetRandomUserCredentials());
6464
SessionHandler<AnonymousSession> session_handler(std::move(session), client,
@@ -97,27 +97,27 @@ TEST(SessionHandlerTest, BEH_EncryptDecryptAnonymousSession) {
9797

9898
TEST(SessionHandlerTest, FUNC_Login) {
9999
routing::Parameters::append_local_live_port_endpoint = true;
100-
BootstrapInfo bootstrap_info;
100+
routing::BootstrapContacts bootstrap_contacts;
101101
auto user_credentials_tuple(GetRandomUserCredentialsTuple());
102102
auto maid_and_signer(passport::CreateMaidAndSigner());
103103
{
104104
LOG(kInfo) << "SessionHandlerTest -- Creating new account --";
105-
Client client(maid_and_signer, bootstrap_info);
105+
Client client(maid_and_signer, bootstrap_contacts);
106106
AnonymousSession session(maid_and_signer);
107107
authentication::UserCredentials user_credentials(MakeUserCredentials(user_credentials_tuple));
108108
SessionHandler<AnonymousSession> session_handler(std::move(session), client,
109109
std::move(user_credentials));
110110
}
111111
try {
112112
LOG(kInfo) << "SessionHandlerTest -- Login for existing account --";
113-
SessionHandler<AnonymousSession> session_handler(bootstrap_info);
113+
SessionHandler<AnonymousSession> session_handler(bootstrap_contacts);
114114
LOG(kInfo) << "About to Login .. ";
115115
authentication::UserCredentials user_credentials(MakeUserCredentials(user_credentials_tuple));
116116
session_handler.Login(std::move(user_credentials));
117117
LOG(kInfo) << "Login successful !";
118118
ASSERT_TRUE(maid_and_signer.first.name() ==
119119
session_handler.session().passport->GetMaid().name());
120-
Client client(session_handler.session().passport->GetMaid(), bootstrap_info);
120+
Client client(session_handler.session().passport->GetMaid(), bootstrap_contacts);
121121
LOG(kInfo) << "Client connection to account successful !";
122122
} catch (std::exception& e) {
123123
LOG(kError) << "Error on Login :" << boost::diagnostic_information(e);
@@ -127,27 +127,27 @@ TEST(SessionHandlerTest, FUNC_Login) {
127127

128128
TEST(SessionHandlerTest, FUNC_Save) {
129129
routing::Parameters::append_local_live_port_endpoint = true;
130-
BootstrapInfo bootstrap_info;
130+
routing::BootstrapContacts bootstrap_contacts;
131131
auto user_credentials_tuple(GetRandomUserCredentialsTuple());
132132
auto maid_and_signer(passport::CreateMaidAndSigner());
133133
{
134134
LOG(kInfo) << "SessionHandlerTest -- Creating new account --";
135-
Client client(maid_and_signer, bootstrap_info);
135+
Client client(maid_and_signer, bootstrap_contacts);
136136
AnonymousSession session(maid_and_signer);
137137
authentication::UserCredentials user_credentials(MakeUserCredentials(user_credentials_tuple));
138138
SessionHandler<AnonymousSession> session_handler(std::move(session), client,
139139
std::move(user_credentials));
140140
}
141141
try {
142142
LOG(kInfo) << "SessionHandlerTest -- Login for existing account --";
143-
SessionHandler<AnonymousSession> session_handler(bootstrap_info);
143+
SessionHandler<AnonymousSession> session_handler(bootstrap_contacts);
144144
LOG(kInfo) << "About to Login .. ";
145145
authentication::UserCredentials user_credentials(MakeUserCredentials(user_credentials_tuple));
146146
session_handler.Login(std::move(user_credentials));
147147
LOG(kInfo) << "Login successful !";
148148
ASSERT_TRUE(maid_and_signer.first.name() ==
149149
session_handler.session().passport->GetMaid().name());
150-
Client client(session_handler.session().passport->GetMaid(), bootstrap_info);
150+
Client client(session_handler.session().passport->GetMaid(), bootstrap_contacts);
151151
LOG(kInfo) << "Client connection to account successful !";
152152
LOG(kInfo) << "SessionHandlerTest -- Saving Session --";
153153
for (int i(0); i != 10; ++i) {

0 commit comments

Comments
 (0)