-
Notifications
You must be signed in to change notification settings - Fork 2.2k
JSON-RPC #382
JSON-RPC #382
Changes from all commits
770d6f9
b970673
e4dd2c0
00bbca9
dd41908
2c58f14
1fc7e1b
3c4da0e
a378709
4ad6113
8816dde
daa23e4
178d80d
aa9f34e
008fd25
d1205fa
d632a3a
cd0a1c4
1b21fa4
83f286a
bfb05d0
21b5e88
18ce0e9
8ccc593
6826f08
57bd143
3342a69
fbd70ac
e645900
acf9bdc
0f304c1
94b83b9
672e56c
df55718
702f283
1bb1b0f
3b9ac15
875a5dc
f9e2c8e
defcdcb
a54b6b1
24a13ec
5001c19
982ef81
1c9ca3d
a2cf4d9
e48f5e0
3689a36
a50ab8b
4633dff
55b9949
deabe1b
4d70abf
4395c68
9b24956
da7f2ae
d7e4416
bd42cb1
b649457
92c1d6e
8fd09e8
c0e7ac4
692426f
70447d1
d8e132c
3b84093
7de3f8a
29e959f
a51e493
8ca8ac7
4d1e8e8
64acc3c
da2ad4b
b7b7601
b62e74b
5ec00a8
74e43cf
0e87d5c
a8a7a15
4879133
e8c4d68
d76a44f
d9baba2
46f278c
9815909
18bf38c
8e71bd1
c1eaa1c
3b5e120
6fefb43
59fc988
c5a1df4
b5b3eb3
d54a2f8
79ee791
95a2c1a
7d24ae8
943d624
8287012
3462f60
bb5ba2d
bab05f0
f5a9c9a
f4af551
cab4784
53edf6d
eb12c3c
5688ae4
0d353de
617a8ae
a014e77
aaf1bfc
c26e564
c2095d4
fafd0ae
cebfa35
8c6af7f
1bf6713
2ee556e
8a568f3
8d1ad00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ ipch | |
*.opensdf | ||
*.suo | ||
|
||
# VIM stuff | ||
*.swp | ||
|
||
#Xcode stuff | ||
build_xc | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
#include <libserpent/funcs.h> | ||
#include <libserpent/util.h> | ||
#include <libdevcrypto/FileSystem.h> | ||
#include <libdevcore/CommonJS.h> | ||
#include <liblll/Compiler.h> | ||
#include <liblll/CodeFragment.h> | ||
#include <libevm/VM.h> | ||
|
@@ -41,6 +42,7 @@ | |
#include <libethereum/Client.h> | ||
#include <libethereum/EthereumHost.h> | ||
#include <libethereum/DownloadMan.h> | ||
#include <libweb3jsonrpc/WebThreeStubServer.h> | ||
#include "DownloadView.h" | ||
#include "MiningView.h" | ||
#include "BuildInfo.h" | ||
|
@@ -83,6 +85,21 @@ static QString fromRaw(dev::h256 _n, unsigned* _inc = nullptr) | |
return QString(); | ||
} | ||
|
||
static std::vector<dev::KeyPair> keysAsVector(QList<dev::KeyPair> const& keys) | ||
{ | ||
auto list = keys.toStdList(); | ||
return {begin(list), end(list)}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Omit std:: |
||
|
||
static QString contentsOfQResource(std::string const& res) | ||
{ | ||
QFile file(QString::fromStdString(res)); | ||
if (!file.open(QFile::ReadOnly)) | ||
BOOST_THROW_EXCEPTION(FileError()); | ||
QTextStream in(&file); | ||
return in.readAll(); | ||
} | ||
|
||
Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f"); | ||
|
||
Main::Main(QWidget *parent) : | ||
|
@@ -131,32 +148,28 @@ Main::Main(QWidget *parent) : | |
connect(ui->ourAccounts->model(), SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(ourAccountsRowsMoved())); | ||
|
||
m_webThree.reset(new WebThreeDirect(string("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/AlethZero", false, {"eth", "shh"})); | ||
m_ldb = new QLDB(this); | ||
|
||
m_server = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(&m_qwebConnector, *web3(), keysAsVector(m_myKeys))); | ||
m_server->setIdentities(keysAsVector(owned())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please confirm: Is owned() keys+identities? Or should there be an identities() method? I don't believe shh and eth keys will be interchangeable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it does do that for now, yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, owned() are keys+identities. I dont know if it is correct. It is the same as in develop branch |
||
m_server->StartListening(); | ||
|
||
connect(ui->webView, &QWebView::loadStarted, [this]() | ||
{ | ||
m_ethereum = nullptr; | ||
m_whisper = nullptr; | ||
// NOTE: no need to delete as QETH_INSTALL_JS_NAMESPACE adopts it. | ||
m_dev = new QDev(this); | ||
m_ethereum = new QEthereum(this, ethereum(), m_myKeys); | ||
m_whisper = new QWhisper(this, whisper(), owned()); | ||
m_qweb = new QWebThree(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see a conflict with m_qweb being re-allocated within loadStarted. That is, when main is deallocated it will call ->clientDieing() on m_qweb. However, QWebThree instances which are implicitly deallocated will not have clientDieing() called on them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in c2095d4 . clientDieing is now called when QWebView is deallocated |
||
auto qweb = m_qweb; | ||
m_qwebConnector.setQWeb(qweb); | ||
|
||
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); | ||
QWebFrame* f = ui->webView->page()->mainFrame(); | ||
f->disconnect(SIGNAL(javaScriptWindowObjectCleared())); | ||
auto qdev = m_dev; | ||
auto qeth = m_ethereum; | ||
auto qshh = m_whisper; | ||
auto qldb = m_ldb; | ||
connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qdev, qeth, qshh, qldb)); | ||
connect(m_whisper, SIGNAL(newIdToAdd(QString)), this, SLOT(addNewId(QString))); | ||
connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qweb)); | ||
connect(m_qweb, SIGNAL(onNewId(QString)), this, SLOT(addNewId(QString))); | ||
}); | ||
|
||
connect(ui->webView, &QWebView::loadFinished, [=]() | ||
{ | ||
m_ethereum->poll(); | ||
m_whisper->poll(); | ||
m_qweb->poll(); | ||
}); | ||
|
||
connect(ui->webView, &QWebView::titleChanged, [=]() | ||
|
@@ -165,9 +178,7 @@ Main::Main(QWidget *parent) : | |
}); | ||
|
||
readSettings(); | ||
|
||
installWatches(); | ||
|
||
startTimer(100); | ||
|
||
{ | ||
|
@@ -184,19 +195,17 @@ Main::~Main() | |
{ | ||
// Must do this here since otherwise m_ethereum'll be deleted (and therefore clearWatches() called by the destructor) | ||
// *after* the client is dead. | ||
m_ethereum->clientDieing(); | ||
m_whisper->faceDieing(); | ||
|
||
m_qweb->clientDieing(); | ||
g_logPost = simpleDebugOut; | ||
writeSettings(); | ||
} | ||
|
||
void Main::addNewId(QString _ids) | ||
{ | ||
Secret _id = toSecret(_ids); | ||
Secret _id = jsToSecret(_ids.toStdString()); | ||
KeyPair kp(_id); | ||
m_myIdentities.push_back(kp); | ||
m_whisper->setIdentities(owned()); | ||
m_server->setIdentities(keysAsVector(owned())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. owned() returning keys+identities (see previous comment) |
||
} | ||
|
||
dev::p2p::NetworkPreferences Main::netPrefs() const | ||
|
@@ -1056,10 +1065,8 @@ void Main::timerEvent(QTimerEvent*) | |
else | ||
interval += 100; | ||
|
||
if (m_ethereum) | ||
m_ethereum->poll(); | ||
if (m_whisper) | ||
m_whisper->poll(); | ||
if (m_qweb) | ||
m_qweb->poll(); | ||
|
||
for (auto const& i: m_handlers) | ||
if (ethereum()->checkWatch(i.first)) | ||
|
@@ -1182,8 +1189,9 @@ void Main::ourAccountsRowsMoved() | |
myKeys.push_back(i); | ||
} | ||
m_myKeys = myKeys; | ||
if (m_ethereum) | ||
m_ethereum->setAccounts(myKeys); | ||
|
||
if (m_server.get()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See: Line 47 |
||
m_server->setAccounts(keysAsVector(m_myKeys)); | ||
} | ||
|
||
void Main::on_inject_triggered() | ||
|
@@ -1629,7 +1637,6 @@ void Main::on_killBlockchain_triggered() | |
ui->net->setChecked(false); | ||
web3()->stopNetwork(); | ||
ethereum()->killChain(); | ||
m_ethereum->setClient(ethereum()); | ||
readSettings(true); | ||
installWatches(); | ||
refreshAll(); | ||
|
@@ -1785,7 +1792,6 @@ void Main::on_debug_clicked() | |
t.gasPrice = gasPrice(); | ||
t.gas = ui->gas->value(); | ||
t.data = m_data; | ||
t.type = isCreation() ? Transaction::ContractCreation : Transaction::MessageCall; | ||
t.receiveAddress = isCreation() ? Address() : fromString(ui->destination->currentText()); | ||
t.sign(s); | ||
auto r = t.rlp(); | ||
|
@@ -2139,20 +2145,22 @@ void Main::on_post_clicked() | |
m.setPayload(dataFromText(ui->shhData->toPlainText())); | ||
Public f = stringToPublic(ui->shhFrom->currentText()); | ||
Secret from; | ||
if (m_whisper->ids().count(f)) | ||
from = m_whisper->ids().at(f); | ||
if (m_server->ids().count(f)) | ||
from = m_server->ids().at(f); | ||
whisper()->inject(m.seal(from, topicFromText(ui->shhTopic->toPlainText()), ui->shhTtl->value(), ui->shhWork->value())); | ||
} | ||
|
||
void Main::on_newIdentity_triggered() | ||
{ | ||
m_whisper->makeIdentity(); | ||
KeyPair kp = KeyPair::create(); | ||
m_myIdentities.append(kp); | ||
m_server->setIdentities(keysAsVector(owned())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. owned() returning keys+identities (see previous comment) |
||
} | ||
|
||
void Main::refreshWhisper() | ||
{ | ||
ui->shhFrom->clear(); | ||
for (auto i: m_whisper->ids()) | ||
for (auto i: m_server ->ids()) | ||
ui->shhFrom->addItem(QString::fromStdString(toHex(i.first.ref()))); | ||
} | ||
|
||
|
@@ -2163,7 +2171,7 @@ void Main::refreshWhispers() | |
{ | ||
shh::Envelope const& e = w.second; | ||
shh::Message m; | ||
for (pair<Public, Secret> const& i: m_whisper->ids()) | ||
for (pair<Public, Secret> const& i: m_server->ids()) | ||
if (!!(m = e.open(i.second))) | ||
break; | ||
if (!m) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
Q_INIT_RESOURCE(js); | ||
Main w; | ||
w.show(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to if (NOT HEADLESS)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is correct as it is, if (NOT HEADLES) is checked earlier