Skip to content

Commit

Permalink
remove depency on readline
Browse files Browse the repository at this point in the history
  • Loading branch information
moneroexamples committed Mar 9, 2018
1 parent 605c6ca commit 3a055f9
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 82 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@ set(LIBRARIES
blocks
lmdb
ringct
ringct_basic

This comment has been minimized.

Copy link
@stoffu

stoffu Mar 9, 2018

Contributor

This is introduced in monero-project/monero#3350 which is not merged yet.

device
common
mnemonics
easylogging
checkpoints
version
epee_readline
epee
readline
${Boost_LIBRARIES}
pthread
unbound
Expand All @@ -127,7 +126,7 @@ set(LIBRARIES
ssl)

if(APPLE)
set(LIBRARIES ${LIBRARIES} "-framework IOKit")
set(LIBRARIES ${LIBRARIES} "-framework IOKit -framework PCSC")
else()
set(LIBRARIES ${LIBRARIES} atomic)
endif()
Expand Down
13 changes: 7 additions & 6 deletions cmake/FindMonero.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# (c) 2014-2016 cpp-ethereum contributors.
#------------------------------------------------------------------------------

set(LIBS common;blocks;cryptonote_basic;cryptonote_core;epee_readline;
set(LIBS common;blocks;cryptonote_basic;cryptonote_core;
cryptonote_protocol;daemonizer;mnemonics;epee;lmdb;device;
blockchain_db;ringct;wallet;cncrypto;easylogging;version;checkpoints)

Expand Down Expand Up @@ -57,11 +57,12 @@ foreach (l ${LIBS})

endforeach()

#if (EXISTS ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
# add_library(easylogging STATIC IMPORTED)
# set_property(TARGET easylogging
# PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
#endif()
if (EXISTS ${MONERO_BUILD_DIR}/src/ringct/libringct_basic.a)
add_library(ringct_basic STATIC IMPORTED)
set_property(TARGET ringct_basic
PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/src/ringct/libringct_basic.a)
endif()


message(STATUS ${MONERO_SOURCE_DIR}/build)

Expand Down
27 changes: 21 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ main(int ac, const char* av[])
auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file");
auto no_blocks_on_index_opt = opts.get_option<string>("no-blocks-on-index");
auto testnet_url = opts.get_option<string>("testnet-url");
auto stagenet_url = opts.get_option<string>("stagenet-url");
auto mainnet_url = opts.get_option<string>("mainnet-url");
auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout");
auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time");
auto testnet_opt = opts.get_option<bool>("testnet");
auto stagenet_opt = opts.get_option<bool>("stagenet");
auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker");
auto enable_output_key_checker_opt = opts.get_option<bool>("enable-output-key-checker");
auto enable_autorefresh_option_opt = opts.get_option<bool>("enable-autorefresh-option");
Expand All @@ -69,6 +71,16 @@ main(int ac, const char* av[])


bool testnet {*testnet_opt};
bool stagenet {*stagenet_opt};
if (testnet && stagenet)
{
cerr << "testnet and stagenet cannot be specified at the same time!" << endl;
return EXIT_FAILURE;
}
const cryptonote::network_type nettype = testnet ?
cryptonote::network_type::TESTNET : stagenet ?
cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;

bool enable_pusher {*enable_pusher_opt};
bool enable_js {*enable_js_opt};
bool enable_key_image_checker {*enable_key_image_checker_opt};
Expand Down Expand Up @@ -128,7 +140,7 @@ main(int ac, const char* av[])
// get blockchain path
path blockchain_path;

if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path, testnet))
if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path, nettype))
{
cerr << "Error getting blockchain path." << endl;
return EXIT_FAILURE;
Expand All @@ -154,6 +166,8 @@ main(int ac, const char* av[])

if (testnet && deamon_url == "http:://127.0.0.1:18081")
deamon_url = "http:://127.0.0.1:28081";
if (stagenet && deamon_url == "http:://127.0.0.1:18081")
deamon_url = "http:://127.0.0.1:38081";

uint64_t mempool_info_timeout {5000};

Expand Down Expand Up @@ -187,8 +201,8 @@ main(int ac, const char* av[])

xmreg::CurrentBlockchainStatus::blockchain_path
= blockchain_path;
xmreg::CurrentBlockchainStatus::testnet
= testnet;
xmreg::CurrentBlockchainStatus::nettype
= nettype;
xmreg::CurrentBlockchainStatus::deamon_url
= deamon_url;
xmreg::CurrentBlockchainStatus::set_blockchain_variables(
Expand All @@ -204,8 +218,8 @@ main(int ac, const char* av[])

xmreg::MempoolStatus::blockchain_path
= blockchain_path;
xmreg::MempoolStatus::testnet
= testnet;
xmreg::MempoolStatus::nettype
= nettype;
xmreg::MempoolStatus::deamon_url
= deamon_url;
xmreg::MempoolStatus::set_blockchain_variables(
Expand Down Expand Up @@ -236,7 +250,7 @@ main(int ac, const char* av[])
xmreg::page xmrblocks(&mcore,
core_storage,
deamon_url,
testnet,
nettype,
enable_pusher,
enable_js,
enable_key_image_checker,
Expand All @@ -249,6 +263,7 @@ main(int ac, const char* av[])
no_blocks_on_index,
mempool_info_timeout,
*testnet_url,
*stagenet_url,
*mainnet_url);

// crow instance
Expand Down
8 changes: 6 additions & 2 deletions src/CmdLineOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace xmreg
"produce help message")
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
"use testnet blockchain")
("stagenet,s", value<bool>()->default_value(false)->implicit_value(true),
"use stagenet blockchain")
("enable-pusher", value<bool>()->default_value(false)->implicit_value(true),
"enable signed transaction pusher")
("enable-mixin-details", value<bool>()->default_value(false)->implicit_value(true),
Expand All @@ -50,9 +52,11 @@ namespace xmreg
("port,p", value<string>()->default_value("8081"),
"default explorer port")
("testnet-url", value<string>()->default_value(""),
"you can specify testnet url, if you run it on mainnet. link will show on front page to testnet explorer")
"you can specify testnet url, if you run it on mainnet or stagenet. link will show on front page to testnet explorer")
("stagenet-url", value<string>()->default_value(""),
"you can specify stagenet url, if you run it on mainnet or testnet. link will show on front page to stagenet explorer")
("mainnet-url", value<string>()->default_value(""),
"you can specify mainnet url, if you run it on testnet. link will show on front page to mainnet explorer")
"you can specify mainnet url, if you run it on testnet or stagenet. link will show on front page to mainnet explorer")
("no-blocks-on-index", value<string>()->default_value("10"),
"number of last blocks to be shown on index page")
("mempool-info-timeout", value<string>()->default_value("5000"),
Expand Down
2 changes: 1 addition & 1 deletion src/CurrentBlockchainStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ CurrentBlockchainStatus::is_thread_running()

bf::path CurrentBlockchainStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};

bool CurrentBlockchainStatus::testnet {false};
cryptonote::network_type CurrentBlockchainStatus::nettype {cryptonote::network_type::MAINNET};

string CurrentBlockchainStatus::output_file {"emission_amount.txt"};

Expand Down
2 changes: 1 addition & 1 deletion src/CurrentBlockchainStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct CurrentBlockchainStatus

static bf::path blockchain_path;

static bool testnet;
static cryptonote::network_type nettype;

static string output_file;

Expand Down
25 changes: 16 additions & 9 deletions src/MempoolStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ MempoolStatus::read_mempool()
const array<uint64_t, 4>& sum_data = summary_of_in_out_rct(
tx, output_pub_keys, input_key_imgs);



double tx_size = static_cast<double>(_tx_info.blob_size)/1024.0;

double payed_for_kB = XMR_AMOUNT(_tx_info.fee) / tx_size;

last_tx.receive_time = _tx_info.receive_time;

last_tx.sum_outputs = sum_data[0];
Expand All @@ -162,15 +168,15 @@ MempoolStatus::read_mempool()
last_tx.mixin_no = sum_data[2];
last_tx.num_nonrct_inputs = sum_data[3];

last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}", false);
last_tx.xmr_inputs_str = xmreg::xmr_amount_to_str(last_tx.sum_inputs , "{:0.3f}");
last_tx.xmr_outputs_str = xmreg::xmr_amount_to_str(last_tx.sum_outputs, "{:0.3f}");
last_tx.timestamp_str = xmreg::timestamp_to_str_gm(_tx_info.receive_time);
last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}", false);
last_tx.payed_for_kB_str = fmt::format("{:0.3f}", payed_for_kB);
last_tx.xmr_inputs_str = xmreg::xmr_amount_to_str(last_tx.sum_inputs , "{:0.3f}");
last_tx.xmr_outputs_str = xmreg::xmr_amount_to_str(last_tx.sum_outputs, "{:0.3f}");
last_tx.timestamp_str = xmreg::timestamp_to_str_gm(_tx_info.receive_time);

last_tx.txsize = fmt::format("{:0.2f}",
static_cast<double>(_tx_info.blob_size)/1024.0);
last_tx.txsize = fmt::format("{:0.2f}", tx_size);

last_tx.pID = '-';
last_tx.pID = '-';

crypto::hash payment_id;
crypto::hash8 payment_id8;
Expand Down Expand Up @@ -253,7 +259,8 @@ MempoolStatus::read_network_info()
local_copy.outgoing_connections_count = rpc_network_info.outgoing_connections_count;
local_copy.incoming_connections_count = rpc_network_info.incoming_connections_count;
local_copy.white_peerlist_size = rpc_network_info.white_peerlist_size;
local_copy.testnet = rpc_network_info.testnet;
local_copy.nettype = rpc_network_info.testnet ? cryptonote::network_type::TESTNET :
rpc_network_info.stagenet ? cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty;
local_copy.block_size_limit = rpc_network_info.block_size_limit;
local_copy.start_time = rpc_network_info.start_time;
Expand Down Expand Up @@ -297,7 +304,7 @@ MempoolStatus::is_thread_running()

bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};
string MempoolStatus::deamon_url {"http:://127.0.0.1:18081"};
bool MempoolStatus::testnet {false};
cryptonote::network_type MempoolStatus::nettype {cryptonote::network_type::MAINNET};
atomic<bool> MempoolStatus::is_running {false};
boost::thread MempoolStatus::m_thread;
Blockchain* MempoolStatus::core_storage {nullptr};
Expand Down
5 changes: 3 additions & 2 deletions src/MempoolStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct MempoolStatus
uint64_t mixin_no {0};

string fee_str;
string payed_for_kB_str;
string xmr_inputs_str;
string xmr_outputs_str;
string timestamp_str;
Expand Down Expand Up @@ -66,7 +67,7 @@ struct MempoolStatus
uint64_t incoming_connections_count {0};
uint64_t white_peerlist_size {0};
uint64_t grey_peerlist_size {0};
bool testnet {false};
cryptonote::network_type nettype {cryptonote::network_type::MAINNET};
crypto::hash top_block_hash;
uint64_t cumulative_difficulty {0};
uint64_t block_size_limit {0};
Expand Down Expand Up @@ -119,7 +120,7 @@ struct MempoolStatus

static bf::path blockchain_path;
static string deamon_url;
static bool testnet;
static cryptonote::network_type nettype;

// make object for accessing the blockchain here
static MicroCore* mcore;
Expand Down
12 changes: 10 additions & 2 deletions src/MicroCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ namespace xmreg
MicroCore::MicroCore():
m_mempool(m_blockchain_storage),
m_blockchain_storage(m_mempool)
{}
{
m_device = &hw::get_device("default");
}


/**
Expand Down Expand Up @@ -88,7 +90,7 @@ MicroCore::init(const string& _blockchain_path)

// initialize Blockchain object to manage
// the database.
return m_blockchain_storage.init(db, m_hardfork, false);
return m_blockchain_storage.init(db, m_hardfork, network_type::MAINNET);
}

/**
Expand Down Expand Up @@ -358,4 +360,10 @@ MicroCore::get_blkchain_path()
return blockchain_path;
}

hw::device* const
MicroCore::get_device() const
{
return m_device;
}

}
4 changes: 4 additions & 0 deletions src/MicroCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace xmreg
tx_memory_pool m_mempool;
Blockchain m_blockchain_storage;

hw::device* m_device;

public:
MicroCore();

Expand Down Expand Up @@ -67,6 +69,8 @@ namespace xmreg
string
get_blkchain_path();

hw::device* const
get_device() const;

virtual ~MicroCore();
};
Expand Down
1 change: 1 addition & 0 deletions src/monero_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_db/lmdb/db_lmdb.h"
#include "device/device_default.hpp"

#include "wallet/wallet2.h"

Expand Down

0 comments on commit 3a055f9

Please sign in to comment.