[FWN] It seems to work now...
This commit is contained in:
parent
d324a78809
commit
f3a044d963
6 changed files with 68 additions and 38 deletions
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
#include <graphene/chain/protocol/types.hpp>
|
#include <graphene/chain/protocol/types.hpp>
|
||||||
|
#include <graphene/time/time.hpp>
|
||||||
|
|
||||||
#include <graphene/egenesis/egenesis.hpp>
|
#include <graphene/egenesis/egenesis.hpp>
|
||||||
|
|
||||||
|
|
@ -240,19 +241,18 @@ namespace detail {
|
||||||
if( _options->count("resync-blockchain") )
|
if( _options->count("resync-blockchain") )
|
||||||
_chain_db->wipe(_data_dir / "blockchain", true);
|
_chain_db->wipe(_data_dir / "blockchain", true);
|
||||||
|
|
||||||
|
flat_map<uint32_t,block_id_type> loaded_checkpoints;
|
||||||
if( _options->count("checkpoint") )
|
if( _options->count("checkpoint") )
|
||||||
{
|
{
|
||||||
auto cps = _options->at("checkpoint").as<vector<string>>();
|
auto cps = _options->at("checkpoint").as<vector<string>>();
|
||||||
flat_map<uint32_t,block_id_type> loaded_checkpoints;
|
|
||||||
loaded_checkpoints.reserve( cps.size() );
|
loaded_checkpoints.reserve( cps.size() );
|
||||||
for( auto cp : cps )
|
for( auto cp : cps )
|
||||||
{
|
{
|
||||||
auto item = fc::json::from_string(cp).as<std::pair<uint32_t,block_id_type> >();
|
auto item = fc::json::from_string(cp).as<std::pair<uint32_t,block_id_type> >();
|
||||||
loaded_checkpoints[item.first] = item.second;
|
loaded_checkpoints[item.first] = item.second;
|
||||||
}
|
}
|
||||||
_chain_db->add_checkpoints( loaded_checkpoints );
|
|
||||||
}
|
}
|
||||||
|
_chain_db->add_checkpoints( loaded_checkpoints );
|
||||||
|
|
||||||
if( _options->count("replay-blockchain") )
|
if( _options->count("replay-blockchain") )
|
||||||
{
|
{
|
||||||
|
|
@ -265,6 +265,18 @@ namespace detail {
|
||||||
_chain_db->reindex(_data_dir / "blockchain", initial_state());
|
_chain_db->reindex(_data_dir / "blockchain", initial_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_options->count("genesis-json") &&
|
||||||
|
_chain_db->get_global_properties().chain_id != graphene::egenesis::get_egenesis_chain_id()) {
|
||||||
|
elog("Detected old database. Nuking and starting over.");
|
||||||
|
_chain_db->wipe(_data_dir / "blockchain", true);
|
||||||
|
_chain_db.reset();
|
||||||
|
_chain_db = std::make_shared<chain::database>();
|
||||||
|
_chain_db->add_checkpoints(loaded_checkpoints);
|
||||||
|
_chain_db->open(_data_dir / "blockchain", initial_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
graphene::time::now();
|
||||||
|
|
||||||
if( _options->count("apiaccess") )
|
if( _options->count("apiaccess") )
|
||||||
_apiaccess = fc::json::from_file( _options->at("apiaccess").as<boost::filesystem::path>() )
|
_apiaccess = fc::json::from_file( _options->at("apiaccess").as<boost::filesystem::path>() )
|
||||||
.as<api_access>();
|
.as<api_access>();
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit cb006ba03c9bf67e6e7cf6a4a8387d387aa4bd3c
|
Subproject commit 9c868b3927a7c0aad3f628ad0071c92f11a0923c
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
BlockChain::BlockChain()
|
BlockChain::BlockChain()
|
||||||
: chainThread(fc::thread::current()),
|
: chainThread(new fc::thread("chainThread")),
|
||||||
fcTaskScheduler(new QTimer(this)),
|
fcTaskScheduler(new QTimer(this)),
|
||||||
grapheneApp(new graphene::app::application)
|
grapheneApp(new graphene::app::application)
|
||||||
{
|
{
|
||||||
|
|
@ -25,25 +25,33 @@ BlockChain::BlockChain()
|
||||||
fcTaskScheduler->start();
|
fcTaskScheduler->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockChain::~BlockChain(){
|
BlockChain::~BlockChain() {
|
||||||
grapheneApp->shutdown_plugins();
|
startFuture.cancel_and_wait(__FUNCTION__);
|
||||||
|
chainThread->async([this] {
|
||||||
|
grapheneApp->shutdown_plugins();
|
||||||
|
delete grapheneApp;
|
||||||
|
}).wait();
|
||||||
|
delete chainThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockChain::start()
|
void BlockChain::start()
|
||||||
{
|
{
|
||||||
try {
|
startFuture = chainThread->async([this] {
|
||||||
grapheneApp->register_plugin<graphene::account_history::account_history_plugin>();
|
try {
|
||||||
grapheneApp->register_plugin<graphene::market_history::market_history_plugin>();
|
grapheneApp->register_plugin<graphene::account_history::account_history_plugin>();
|
||||||
|
grapheneApp->register_plugin<graphene::market_history::market_history_plugin>();
|
||||||
|
|
||||||
QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
QDir(dataDir).mkpath(".");
|
QDir(dataDir).mkpath(".");
|
||||||
boost::program_options::variables_map map;
|
boost::program_options::variables_map map;
|
||||||
map.insert({"rpc-endpoint",boost::program_options::variable_value(std::string("127.0.0.1:8090"), false)});
|
map.insert({"rpc-endpoint",boost::program_options::variable_value(std::string("127.0.0.1:8090"), false)});
|
||||||
map.insert({"seed-node",boost::program_options::variable_value(std::vector<std::string>{("104.200.28.117:61705")}, false)});
|
map.insert({"seed-node",boost::program_options::variable_value(std::vector<std::string>{("104.200.28.117:61705")}, false)});
|
||||||
grapheneApp->initialize(dataDir.toStdString(), map);
|
grapheneApp->initialize(dataDir.toStdString(), map);
|
||||||
grapheneApp->startup();
|
grapheneApp->startup();
|
||||||
grapheneApp->startup_plugins();
|
grapheneApp->startup_plugins();
|
||||||
} catch (const fc::exception& e) {
|
} catch (const fc::exception& e) {
|
||||||
elog("Crap went wrong: ${e}", ("e", e.to_detail_string()));
|
elog("Crap went wrong: ${e}", ("e", e.to_detail_string()));
|
||||||
}
|
}
|
||||||
|
QMetaObject::invokeMethod(this, "started");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <fc/thread/future.hpp>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
@ -9,9 +11,10 @@ namespace graphene { namespace app { class application; } }
|
||||||
class BlockChain : public QObject {
|
class BlockChain : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
fc::thread& chainThread;
|
fc::thread* chainThread;
|
||||||
QTimer* fcTaskScheduler;
|
QTimer* fcTaskScheduler;
|
||||||
graphene::app::application* grapheneApp;
|
graphene::app::application* grapheneApp;
|
||||||
|
fc::future<void> startFuture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BlockChain();
|
BlockChain();
|
||||||
|
|
@ -19,4 +22,7 @@ public:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void started();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,13 @@ int main(int argc, char *argv[])
|
||||||
app.setOrganizationDomain("cryptonomex.org");
|
app.setOrganizationDomain("cryptonomex.org");
|
||||||
app.setOrganizationName("Cryptonomex, Inc.");
|
app.setOrganizationName("Cryptonomex, Inc.");
|
||||||
|
|
||||||
QThread chainThread;
|
|
||||||
fc::promise<BlockChain*>::ptr chain = new fc::promise<BlockChain*>;
|
|
||||||
QObject::connect(&chainThread, &QThread::started, [&app, &chain] {
|
|
||||||
chain->set_value(new BlockChain);
|
|
||||||
});
|
|
||||||
chainThread.start();
|
|
||||||
|
|
||||||
QtWebEngine::initialize();
|
QtWebEngine::initialize();
|
||||||
fc::http::server webGuiServer;
|
fc::http::server webGuiServer;
|
||||||
fc::thread serverThread("HTTP server thread");
|
fc::thread serverThread("HTTP server thread");
|
||||||
serverThread.async([&webGuiServer] {
|
serverThread.async([&webGuiServer] {
|
||||||
webGuiServer.listen(fc::ip::endpoint::from_string("127.0.0.1:8080"));
|
webGuiServer.listen(fc::ip::endpoint::from_string("127.0.0.1:8080"));
|
||||||
webGuiServer.on_request([](const fc::http::request& request, const fc::http::server::response& response) {
|
webGuiServer.on_request([](const fc::http::request& request, const fc::http::server::response& response) {
|
||||||
QString path = QStringLiteral("/Users/nathan/graphene-ui/web/bundle") + QString::fromStdString(request.path);
|
QString path = QStringLiteral("/Users/nathan/graphene-ui/web/dist") + QString::fromStdString(request.path);
|
||||||
if (path.endsWith('/'))
|
if (path.endsWith('/'))
|
||||||
path.append(QStringLiteral("index.html"));
|
path.append(QStringLiteral("index.html"));
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
|
|
@ -52,13 +45,9 @@ int main(int argc, char *argv[])
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
qmlRegisterType<BlockChain>("Graphene.FullNode", 1, 0, "BlockChain");
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
auto chainPtr = chain->wait();
|
|
||||||
engine.rootContext()->setContextProperty(QStringLiteral("blockChain"), chainPtr);
|
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||||
|
|
||||||
auto ret = app.exec();
|
return app.exec();
|
||||||
chainPtr->deleteLater();
|
|
||||||
chainThread.exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,32 @@ import QtQuick 2.5
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import QtWebEngine 1.0
|
import QtWebEngine 1.0
|
||||||
|
|
||||||
|
import Graphene.FullNode 1.0
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id: window
|
id: window
|
||||||
width: Screen.width / 2
|
width: Screen.width / 2
|
||||||
height: Screen.height / 2
|
height: Screen.height / 2
|
||||||
|
visible: true
|
||||||
|
|
||||||
|
BlockChain {
|
||||||
|
id: blockChain
|
||||||
|
onStarted: webView.url = "http://localhost:8080"
|
||||||
|
}
|
||||||
Component.onCompleted: blockChain.start()
|
Component.onCompleted: blockChain.start()
|
||||||
|
|
||||||
Rectangle { anchors.fill: parent; color: "#1F1F1F" }
|
Rectangle { anchors.fill: parent; color: "#1F1F1F" }
|
||||||
|
Text {
|
||||||
|
font.pointSize: 20
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: qsTr("Loading...")
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
WebEngineView {
|
WebEngineView {
|
||||||
|
id: webView
|
||||||
|
visible: false
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
url: "http://localhost:8080"
|
onLoadProgressChanged: if (loadProgress === 100) visible = true
|
||||||
onLoadProgressChanged: if (loadProgress === 100) window.visible = true
|
onJavaScriptConsoleMessage: console.log(JSON.stringify(arguments))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue