Browse Source

User DNS & poc-5.ethdev.com for peerserver.

cl-refactor
Gav Wood 10 years ago
parent
commit
b883f0c135
  1. 22
      alethzero/MainWin.cpp
  2. 6
      exp/main.cpp
  3. 2
      libethereum/DownloadMan.cpp
  4. 2
      libethereum/DownloadMan.h
  5. 3
      libethereum/EthereumHost.h
  6. 5
      libethereum/EthereumPeer.cpp
  7. 3
      libethereum/EthereumPeer.h
  8. 13
      libp2p/Host.cpp
  9. 1
      libp2p/Host.h

22
alethzero/MainWin.cpp

@ -97,25 +97,9 @@ Main::Main(QWidget *parent) :
// ui->log->addItem(QString::fromStdString(s)); // ui->log->addItem(QString::fromStdString(s));
}; };
#if 0&&ETH_DEBUG m_servers.append(QString::fromStdString(Host::pocHost() + ":30303"));
m_servers.append("192.168.0.10:30301"); #if ETH_DEBUG
#else m_servers.append("localhost:30303");
int pocnumber = QString(dev::Version).section('.', 1, 1).toInt();
if (pocnumber == 5)
m_servers.push_back("54.72.69.180:30303");
else if (pocnumber == 6)
m_servers.push_back("54.76.56.74:30303");
else
{
connect(&m_webCtrl, &QNetworkAccessManager::finished, [&](QNetworkReply* _r)
{
m_servers = QString::fromUtf8(_r->readAll()).split("\n", QString::SkipEmptyParts);
});
QNetworkRequest r(QUrl("http://www.ethereum.org/servers.poc" + QString::number(pocnumber) + ".txt"));
r.setHeader(QNetworkRequest::UserAgentHeader, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1712.0 Safari/537.36");
m_webCtrl.get(r);
srand(time(0));
}
#endif #endif
cerr << "State root: " << BlockChain::genesis().stateRoot << endl; cerr << "State root: " << BlockChain::genesis().stateRoot << endl;

6
exp/main.cpp

@ -37,9 +37,9 @@ using namespace dev::shh;
int main() int main()
{ {
DownloadMan man; DownloadMan man;
DownloadSub s0(&man); DownloadSub s0(man);
DownloadSub s1(&man); DownloadSub s1(man);
DownloadSub s2(&man); DownloadSub s2(man);
man.resetToChain(h256s({u256(0), u256(1), u256(2), u256(3), u256(4), u256(5), u256(6), u256(7), u256(8)})); man.resetToChain(h256s({u256(0), u256(1), u256(2), u256(3), u256(4), u256(5), u256(6), u256(7), u256(8)}));
cnote << s0.nextFetch(2); cnote << s0.nextFetch(2);
cnote << s1.nextFetch(2); cnote << s1.nextFetch(2);

2
libethereum/DownloadMan.cpp

@ -24,7 +24,7 @@ using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::eth;
DownloadSub::DownloadSub(DownloadMan* _man): m_man(_man) DownloadSub::DownloadSub(DownloadMan& _man): m_man(&_man)
{ {
WriteGuard l(m_man->x_subs); WriteGuard l(m_man->x_subs);
m_man->m_subs.insert(this); m_man->m_subs.insert(this);

2
libethereum/DownloadMan.h

@ -42,7 +42,7 @@ class DownloadSub
friend class DownloadMan; friend class DownloadMan;
public: public:
DownloadSub(DownloadMan* _man); DownloadSub(DownloadMan& _man);
~DownloadSub(); ~DownloadSub();
/// Finished last fetch - grab the next bunch of block hashes to download. /// Finished last fetch - grab the next bunch of block hashes to download.

3
libethereum/EthereumHost.h

@ -35,6 +35,7 @@
#include <libp2p/Common.h> #include <libp2p/Common.h>
#include "CommonNet.h" #include "CommonNet.h"
#include "EthereumPeer.h" #include "EthereumPeer.h"
#include "DownloadMan.h"
namespace dev namespace dev
{ {
@ -122,6 +123,8 @@ private:
h256Set m_blocksOnWay; h256Set m_blocksOnWay;
DownloadMan m_man;
h256 m_latestBlockSent; h256 m_latestBlockSent;
h256Set m_transactionsSent; h256Set m_transactionsSent;
}; };

5
libethereum/EthereumPeer.cpp

@ -35,7 +35,8 @@ using namespace p2p;
#define clogS(X) dev::LogOutputStream<X, true>(false) << "| " << std::setw(2) << session()->socketId() << "] " #define clogS(X) dev::LogOutputStream<X, true>(false) << "| " << std::setw(2) << session()->socketId() << "] "
EthereumPeer::EthereumPeer(Session* _s, HostCapabilityFace* _h): EthereumPeer::EthereumPeer(Session* _s, HostCapabilityFace* _h):
Capability(_s, _h) Capability(_s, _h),
m_sub(host()->m_man)
{ {
sendStatus(); sendStatus();
} }
@ -90,7 +91,7 @@ void EthereumPeer::tryGrabbingHashChain()
u256 td = max(host()->m_chain.details().totalDifficulty, host()->m_totalDifficultyOfNeeded); u256 td = max(host()->m_chain.details().totalDifficulty, host()->m_totalDifficultyOfNeeded);
clogS(NetAllDetail) << "Attempt chain-grab? Latest:" << c.abridged() << ", number:" << n << ", TD: max(" << host()->m_chain.details().totalDifficulty << "," << host()->m_totalDifficultyOfNeeded << ") versus " << m_totalDifficulty; clogS(NetAllDetail) << "Attempt chain-grab? Latest:" << c.abridged() << ", number:" << n << ", TD: max(" << host()->m_chain.details().totalDifficulty << "," << host()->m_totalDifficultyOfNeeded << ") versus " << m_totalDifficulty;
if (td > m_totalDifficulty) if (td >= m_totalDifficulty)
{ {
clogS(NetAllDetail) << "No. Our chain is better."; clogS(NetAllDetail) << "No. Our chain is better.";
m_grabbing = Grabbing::Nothing; m_grabbing = Grabbing::Nothing;

3
libethereum/EthereumPeer.h

@ -32,6 +32,7 @@
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include <libp2p/Capability.h> #include <libp2p/Capability.h>
#include "CommonNet.h" #include "CommonNet.h"
#include "DownloadMan.h"
namespace dev namespace dev
{ {
@ -94,6 +95,8 @@ private:
std::set<h256> m_knownBlocks; std::set<h256> m_knownBlocks;
std::set<h256> m_knownTransactions; std::set<h256> m_knownTransactions;
std::mutex x_knownTransactions; std::mutex x_knownTransactions;
DownloadSub m_sub;
}; };
} }

13
libp2p/Host.cpp

@ -34,6 +34,7 @@
#include <set> #include <set>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <boost/algorithm/string.hpp>
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include <libethcore/Exceptions.h> #include <libethcore/Exceptions.h>
#include "Session.h" #include "Session.h"
@ -349,12 +350,20 @@ void Host::ensureAccepting()
} }
} }
string Host::pocHost()
{
vector<string> strs;
boost::split(strs, dev::Version, boost::is_any_of("."));
return "poc-" + strs[1] + ".ethdev.com";
}
void Host::connect(std::string const& _addr, unsigned short _port) noexcept void Host::connect(std::string const& _addr, unsigned short _port) noexcept
{ {
try try
{ {
// TODO: actual DNS lookup. bi::tcp::resolver r(m_ioService);
connect(bi::tcp::endpoint(bi::address::from_string(_addr), _port)); connect(r.resolve({_addr, toString(_port)})->endpoint());
// connect(bi::tcp::endpoint(bi::address::from_string(_addr), _port));
} }
catch (exception const& e) catch (exception const& e)
{ {

1
libp2p/Host.h

@ -82,6 +82,7 @@ public:
template <class T> std::shared_ptr<T> cap() const { try { return std::static_pointer_cast<T>(m_capabilities.at(T::staticName())); } catch (...) { return nullptr; } } template <class T> std::shared_ptr<T> cap() const { try { return std::static_pointer_cast<T>(m_capabilities.at(T::staticName())); } catch (...) { return nullptr; } }
/// Connect to a peer explicitly. /// Connect to a peer explicitly.
static std::string pocHost();
void connect(std::string const& _addr, unsigned short _port = 30303) noexcept; void connect(std::string const& _addr, unsigned short _port = 30303) noexcept;
void connect(bi::tcp::endpoint const& _ep); void connect(bi::tcp::endpoint const& _ep);

Loading…
Cancel
Save