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

Commit

Permalink
Move bootnodes list from Host to Common
Browse files Browse the repository at this point in the history
Also rename function from pocHosts to defaultBootNodes
  • Loading branch information
halfalicious committed Feb 13, 2019
1 parent ffea09f commit bad979f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 49 deletions.
5 changes: 3 additions & 2 deletions aleth-bootnode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <libdevcore/FileSystem.h>
#include <libdevcore/LoggingProgramOptions.h>
#include <libethcore/Common.h>
#include <libp2p/Common.h>
#include <libp2p/Host.h>
#include <boost/program_options.hpp>
#include <boost/program_options/options_description.hpp>
Expand Down Expand Up @@ -127,13 +128,13 @@ int main(int argc, char** argv)
Host h(c_programName, netPrefs, &netData);
h.start();
if (!h.haveNetwork())
return -1;
return AlethErrors::NetworkStartFailure;

cout << "Node ID: " << h.enode() << endl;

if (!noBootstrap)
{
for (auto const& bn : Host::pocHosts())
for (auto const& bn : defaultBootNodes())
{
bi::tcp::endpoint ep = Network::resolveHost(bn.second);
h.addNode(
Expand Down
2 changes: 1 addition & 1 deletion aleth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ int main(int argc, char** argv)
web3.addNode(p.first, p.second.first);

if (bootstrap && privateChain.empty())
for (auto const& i : Host::pocHosts())
for (auto const& i : defaultBootNodes())
web3.requirePeer(i.first, i.second);
if (!remoteHost.empty())
web3.addNode(p2p::NodeID(), remoteHost + ":" + toString(remotePort));
Expand Down
17 changes: 17 additions & 0 deletions libp2p/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,22 @@ boost::log::formatting_ostream& operator<<(boost::log::formatting_ostream& _log,
return _log << _node.id << '@' << _node.endpoint;
}

std::unordered_map<Public, std::string> defaultBootNodes()
{
return{
// Mainnet:
{ Public("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c"), "52.16.188.185:30303" },
{ Public("3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99"), "13.93.211.84:30303" },
{ Public("78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"), "191.235.84.50:30303" },
{ Public("158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6"), "13.75.154.138:30303" },
{ Public("1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"), "52.74.57.123:30303" },
// Ropsten:
{ Public("30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606"), "52.176.7.10:30303" },
{ Public("865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c"), "52.176.100.77:30303" },
{ Public("6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f"), "52.232.243.152:30303" },
{ Public("94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09"), "192.81.208.223:30303" },
};
}

} // namespace p2p
} // namespace dev
37 changes: 11 additions & 26 deletions libp2p/Common.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file Common.h
* @author Gav Wood <i@gavwood.com>
* @author Alex Leverington <nessence@gmail.com>
* @date 2014
*
* Miscellanea required for the Host/Session/NodeTable classes.
*/
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.

//
// Miscellanea required for the Host/Session/NodeTable classes.
//

#pragma once

Expand Down Expand Up @@ -313,8 +297,10 @@ class DeadlineOps

/// Simple stream output for a NodeIPEndpoint.
std::ostream& operator<<(std::ostream& _out, NodeIPEndpoint const& _ep);

/// Official Ethereum boot nodes
std::unordered_map<Public, std::string> defaultBootNodes();
}

}

/// std::hash for asio::adress
Expand All @@ -337,5 +323,4 @@ template <> struct hash<bi::address>
return std::hash<std::string>()(_a.to_string());
}
};

}
} // namespace std
17 changes: 0 additions & 17 deletions libp2p/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,23 +472,6 @@ void Host::runAcceptor()
}
}

unordered_map<Public, string> Host::pocHosts()
{
return {
// Mainnet:
{ Public("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c"), "52.16.188.185:30303" },
{ Public("3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99"), "13.93.211.84:30303" },
{ Public("78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"), "191.235.84.50:30303" },
{ Public("158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6"), "13.75.154.138:30303" },
{ Public("1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"), "52.74.57.123:30303" },
// Ropsten:
{ Public("30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606"), "52.176.7.10:30303" },
{ Public("865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c"), "52.176.100.77:30303" },
{ Public("6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f"), "52.232.243.152:30303" },
{ Public("94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09"), "192.81.208.223:30303" },
};
}

void Host::registerCapability(shared_ptr<CapabilityFace> const& _cap)
{
registerCapability(_cap, _cap->name(), _cap->version());
Expand Down
3 changes: 0 additions & 3 deletions libp2p/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ class Host: public Worker
/// Will block on network process events.
virtual ~Host();

/// Default hosts for current version of client.
static std::unordered_map<Public, std::string> pocHosts();

/// Register a host capability; all new peer connections will see this capability.
void registerCapability(std::shared_ptr<CapabilityFace> const& _cap);

Expand Down

0 comments on commit bad979f

Please sign in to comment.