From 4ef410eee032cda9931988d40168ffa2cb1383e1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 11 May 2015 22:37:16 +0300 Subject: [PATCH] Use Go bootnodes. --- alethzero/MainWin.cpp | 5 +++-- eth/main.cpp | 3 ++- libp2p/Host.cpp | 10 ++++++++++ libp2p/Host.h | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 925a04cae..87c9c2dc9 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -173,7 +173,7 @@ Main::Main(QWidget *parent) : QMessageBox::warning(nullptr, "Try again", "You entered two different passwords - please enter the same password twice.", QMessageBox::Ok); } m_keyManager.create(password.toStdString()); - m_keyManager.import(Secret::random(), "{\"name\":\"Default identity\"}"); + m_keyManager.import(Secret::random(), "Default identity"); } #if ETH_DEBUG @@ -1994,7 +1994,8 @@ void Main::on_go_triggered() ui->net->setChecked(true); on_net_triggered(); } - web3()->addNode(p2p::NodeId(), Host::pocHost()); + for (auto const& i: Host::pocHosts()) + web3()->requirePeer(i.first, i.second); } std::string Main::prettyU256(dev::u256 const& _n) const diff --git a/eth/main.cpp b/eth/main.cpp index ba44b15a8..60d454287 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1132,7 +1132,8 @@ int main(int argc, char** argv) cout << "Node ID: " << web3.enode() << endl; if (bootstrap) - web3.addNode(p2p::NodeId(), Host::pocHost()); + for (auto const& i: Host::pocHosts()) + web3.requirePeer(i.first, i.second); if (remoteHost.size()) web3.addNode(p2p::NodeId(), remoteHost + ":" + toString(remotePort)); diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 4560c1564..9b5a6dca7 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -389,6 +389,16 @@ string Host::pocHost() return "poc-" + strs[1] + ".ethdev.com"; } +std::unordered_map const& Host::pocHosts() +{ + static const std::unordered_map c_ret = { +// { Public(""), "poc-9.ethdev.com:30303" }, + { Public("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c"), "52.16.188.185:30303" }, + { Public("7f25d3eab333a6b98a8b5ed68d962bb22c876ffcd5561fca54e3c2ef27f754df6f7fd7c9b74cc919067abac154fb8e1f8385505954f161ae440abc355855e034"), "54.207.93.166:30303" } + }; + return c_ret; +} + void Host::addNode(NodeId const& _node, NodeIPEndpoint const& _endpoint) { // return if network is stopped while waiting on Host::run() or nodeTable to start diff --git a/libp2p/Host.h b/libp2p/Host.h index b9af0e8b0..4cfca7718 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -95,6 +95,8 @@ public: /// Default host for current version of client. static std::string pocHost(); + static std::unordered_map const& pocHosts(); + /// Register a peer-capability; all new peer connections will have this capability. template std::shared_ptr registerCapability(T* _t) { _t->m_host = this; std::shared_ptr ret(_t); m_capabilities[std::make_pair(T::staticName(), T::staticVersion())] = ret; return ret; }