Browse Source

Merge branch 'develop' of https://github.com/ethereum/cpp-ethereum into client_ref

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
f32d27b3b2
  1. 13
      alethzero/DappHost.cpp
  2. 6
      alethzero/DappHost.h
  3. 5
      alethzero/MainWin.cpp
  4. 1
      extdep/getstuff.bat
  5. 2
      test/TestHelper.cpp
  6. 2
      test/TestHelper.h
  7. 2
      test/libdevcore/rlp.cpp

13
alethzero/DappHost.cpp

@ -28,7 +28,11 @@
using namespace dev; using namespace dev;
DappHost::DappHost(int _port, int _threads): DappHost::DappHost(int _port, int _threads):
m_port(_port), m_threads(_threads), m_running(false), m_daemon(nullptr) m_port(_port),
m_url(QString("http://localhost:%1/").arg(m_port)),
m_threads(_threads),
m_running(false),
m_daemon(nullptr)
{ {
startListening(); startListening();
} }
@ -135,5 +139,10 @@ QUrl DappHost::hostDapp(Dapp&& _dapp)
for (ManifestEntry const& entry: m_dapp.manifest.entries) for (ManifestEntry const& entry: m_dapp.manifest.entries)
m_entriesByPath[QString::fromStdString(entry.path)] = &entry; m_entriesByPath[QString::fromStdString(entry.path)] = &entry;
return QUrl(QString("http://localhost:%1/").arg(m_port)); return m_url;
}
bool DappHost::servesUrl(QUrl const& _url) const
{
return m_url == _url || m_url.isParentOf(_url);
} }

6
alethzero/DappHost.h

@ -40,6 +40,9 @@ public:
/// Load and host a dapp. Previsous dapp in discarded. Synchronous /// Load and host a dapp. Previsous dapp in discarded. Synchronous
QUrl hostDapp(Dapp&& _dapp); QUrl hostDapp(Dapp&& _dapp);
/// @returns true if the given url is served from this DappHost.
bool servesUrl(QUrl const& _url) const;
private: private:
void startListening(); void startListening();
void stopListening(); void stopListening();
@ -48,7 +51,8 @@ private:
void sendResponse(std::string const& _url, MHD_Connection* _connection); void sendResponse(std::string const& _url, MHD_Connection* _connection);
static int callback(void* _cls, MHD_Connection* _connection, char const* _url, char const* _method, char const* _version, char const* _uploadData, size_t* _uploadDataSize, void** _conCls); static int callback(void* _cls, MHD_Connection* _connection, char const* _url, char const* _method, char const* _version, char const* _uploadData, size_t* _uploadDataSize, void** _conCls);
int m_port; int const m_port;
QUrl const m_url;
int m_threads; int m_threads;
bool m_running; bool m_running;
MHD_Daemon* m_daemon; MHD_Daemon* m_daemon;

5
alethzero/MainWin.cpp

@ -232,6 +232,11 @@ Main::Main(QWidget *parent) :
{ {
ui->tabWidget->setTabText(0, ui->webView->title()); ui->tabWidget->setTabText(0, ui->webView->title());
}); });
connect(ui->webView, &QWebEngineView::urlChanged, [=](QUrl const& _url)
{
if (!m_dappHost->servesUrl(_url))
ui->urlEdit->setText(_url.toString());
});
m_dappHost.reset(new DappHost(8081)); m_dappHost.reset(new DappHost(8081));
m_dappLoader = new DappLoader(this, web3(), getNameReg()); m_dappLoader = new DappLoader(this, web3(), getNameReg());

1
extdep/getstuff.bat

@ -11,6 +11,7 @@ call :download curl 7.4.2
call :download jsoncpp 1.6.2 call :download jsoncpp 1.6.2
call :download json-rpc-cpp 0.5.0 call :download json-rpc-cpp 0.5.0
call :download leveldb 1.2 call :download leveldb 1.2
call :download llvm 3.7svn
call :download microhttpd 0.9.2 call :download microhttpd 0.9.2
call :download qt 5.4.1 call :download qt 5.4.1
call :download miniupnpc 1.9 call :download miniupnpc 1.9

2
test/TestHelper.cpp

@ -767,6 +767,8 @@ Options::Options()
wallet = true; wallet = true;
else if (arg == "--nonetwork") else if (arg == "--nonetwork")
nonetwork = true; nonetwork = true;
else if (arg == "--network")
nonetwork = false;
else if (arg == "--nodag") else if (arg == "--nodag")
nodag = true; nodag = true;
else if (arg == "--all") else if (arg == "--all")

2
test/TestHelper.h

@ -224,7 +224,7 @@ public:
bool inputLimits = false; bool inputLimits = false;
bool bigData = false; bool bigData = false;
bool wallet = false; bool wallet = false;
bool nonetwork = false; bool nonetwork = true;
bool nodag = true; bool nodag = true;
/// @} /// @}

2
test/libdevcore/rlp.cpp

@ -71,6 +71,7 @@ namespace dev
{ {
bytes payloadToDecode = fromHex(o["out"].get_str()); bytes payloadToDecode = fromHex(o["out"].get_str());
RLP payload(payloadToDecode); RLP payload(payloadToDecode);
ostringstream() << payload;
if (payload.isEmpty()) if (payload.isEmpty())
BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Decoded Empty RLP!")); BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Decoded Empty RLP!"));
o["in"] = "VALID"; o["in"] = "VALID";
@ -128,6 +129,7 @@ namespace dev
{ {
bytes payloadToDecode = fromHex(o["out"].get_str()); bytes payloadToDecode = fromHex(o["out"].get_str());
RLP payload(payloadToDecode); RLP payload(payloadToDecode);
ostringstream() << payload;
if (rlpType == RlpType::Test) if (rlpType == RlpType::Test)
dev::test::checkRLPAgainstJson(inputData, payload); dev::test::checkRLPAgainstJson(inputData, payload);

Loading…
Cancel
Save