forked from lthn/blockchain
Merge branch 'master' into frontend
This commit is contained in:
commit
8f49b6b84f
10 changed files with 66 additions and 7 deletions
|
|
@ -125,6 +125,7 @@ namespace epee
|
|||
template<class stl_container, class t_storage>
|
||||
static bool serialize_stl_container_pod_val_as_blob(const stl_container& container, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
|
||||
{
|
||||
static_assert(std::is_trivial<typename stl_container::value_type>::value, "Item supposed to be 'trivial'(trivially copyable)");
|
||||
if(!container.size()) return true;
|
||||
std::string mb;
|
||||
mb.resize(sizeof(typename stl_container::value_type)*container.size());
|
||||
|
|
@ -140,6 +141,7 @@ namespace epee
|
|||
template<class stl_container, class t_storage>
|
||||
static bool unserialize_stl_container_pod_val_as_blob(stl_container& container, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
|
||||
{
|
||||
static_assert(std::is_trivial<typename stl_container::value_type>::value, "Item supposed to be 'trivial'(trivially copyable)");
|
||||
container.clear();
|
||||
std::string buff;
|
||||
bool res = stg.get_value(pname, buff, hparent_section);
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ namespace tools
|
|||
if (txe.count == 0 || (txe.read_only && txe.count == 1))
|
||||
{
|
||||
mdb_txn_abort(txe.ptx);
|
||||
if (!txe.read_only && txe.count)
|
||||
if (!txe.read_only && !txe.count)
|
||||
{
|
||||
CRITICAL_SECTION_UNLOCK(m_write_exclusive_lock);
|
||||
LOG_PRINT_CYAN("[DB " << m_path << "] WRITE UNLOCKED(ABORTED)", LOG_LEVEL_3);
|
||||
|
|
|
|||
|
|
@ -1733,6 +1733,9 @@ bool blockchain_storage::get_main_block_rpc_details(uint64_t i, block_rpc_extend
|
|||
CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
auto core_bei_ptr = m_db_blocks[i];
|
||||
crypto::hash id = get_block_hash(core_bei_ptr->bl);
|
||||
crypto::hash pow_seed = null_hash;
|
||||
get_seed_for_scratchpad(i, pow_seed);
|
||||
bei.pow_seed = epee::string_tools::pod_to_hex(pow_seed);
|
||||
bei.is_orphan = false;
|
||||
bei.total_fee = 0;
|
||||
bei.total_txs_size = 0;
|
||||
|
|
@ -4303,7 +4306,8 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
|||
if (!check_hash(proof_hash, current_diffic))
|
||||
{
|
||||
LOG_ERROR("Block with id: " << id << ENDL
|
||||
<< " : " << proof_hash << ENDL
|
||||
<< "PoW hash: " << proof_hash << ENDL
|
||||
<< "PoW seed: " << m_current_scratchpad_seed << ENDL
|
||||
<< "unexpected difficulty: " << current_diffic);
|
||||
bvc.m_verification_failed = true;
|
||||
return false;
|
||||
|
|
@ -5323,6 +5327,7 @@ bool blockchain_storage::validate_alt_block_ms_input(const transaction& input_tx
|
|||
bool blockchain_storage::get_seed_for_scratchpad(uint64_t height, crypto::hash& seed)const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
LOG_PRINT_MAGENTA("Get seed for scratchpad [main_chain] on height " << height, LOG_LEVEL_0);
|
||||
return get_seed_for_scratchpad_cb(height, seed, [&](uint64_t index) -> crypto::hash
|
||||
{
|
||||
return get_block_hash(m_db_blocks[index]->bl);
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ namespace currency
|
|||
crypto::hash genesis_seed = null_hash;
|
||||
bool r = epee::string_tools::hex_to_pod(CURRENCY_SCRATCHPAD_GENESIS_SEED, genesis_seed);
|
||||
CHECK_AND_ASSERT_THROW_MES(r, "Unable to parse CURRENCY_SCRATCHPAD_GENESIS_SEED " << CURRENCY_SCRATCHPAD_GENESIS_SEED);
|
||||
LOG_PRINT_MAGENTA("[SCRATCHPAD] GENESIS SEED SELECTED: " << genesis_seed, LOG_LEVEL_1);
|
||||
LOG_PRINT_MAGENTA("[SCRATCHPAD] GENESIS SEED SELECTED: " << genesis_seed, LOG_LEVEL_0);
|
||||
seed = genesis_seed;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -688,7 +688,7 @@ namespace currency
|
|||
}
|
||||
seed = crypto::cn_fast_hash(&seed_data[0], sizeof(seed_data[0]) * seed_data.size());
|
||||
|
||||
LOG_PRINT_MAGENTA("[SCRATCHPAD] SEED SELECTED: h = " << last_upd_h << ", selector: " << selector_id << ENDL << ss.str() << "SEED: " << seed, LOG_LEVEL_1);
|
||||
LOG_PRINT_MAGENTA("[SCRATCHPAD] SEED SELECTED: h = " << last_upd_h << ", selector: " << selector_id << ENDL << ss.str() << "SEED: " << seed, LOG_LEVEL_0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ int main(int argc, char* argv[])
|
|||
ccore.set_currency_protocol(&cprotocol);
|
||||
daemon_cmmands_handler dch(p2psrv, rpc_server);
|
||||
tools::miniupnp_helper upnp_helper;
|
||||
ccore.get_blockchain_storage().get_attachment_services_manager().add_service(&offers_service);
|
||||
//ccore.get_blockchain_storage().get_attachment_services_manager().add_service(&offers_service);
|
||||
|
||||
if (command_line::get_arg(vm, command_line::arg_show_rpc_autodoc))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
m_cmd_binder.set_handler("print_market", boost::bind(&daemon_cmmands_handler::print_market, this, _1));
|
||||
m_cmd_binder.set_handler("print_bc_outs_stat", boost::bind(&daemon_cmmands_handler::print_bc_outs_stat, this, _1));
|
||||
m_cmd_binder.set_handler("print_block", boost::bind(&daemon_cmmands_handler::print_block, this, _1), "Print block, print_block <block_hash> | <block_height>");
|
||||
m_cmd_binder.set_handler("print_block_info", boost::bind(&daemon_cmmands_handler::print_block_info, this, _1), "Print block info, print_block <block_hash> | <block_height>");
|
||||
m_cmd_binder.set_handler("print_tx", boost::bind(&daemon_cmmands_handler::print_tx, this, _1), "Print transaction, print_tx <transaction_hash>");
|
||||
m_cmd_binder.set_handler("start_mining", boost::bind(&daemon_cmmands_handler::start_mining, this, _1), "Start mining for specified address, start_mining <addr> [threads=1]");
|
||||
m_cmd_binder.set_handler("stop_mining", boost::bind(&daemon_cmmands_handler::stop_mining, this, _1), "Stop mining");
|
||||
|
|
@ -390,6 +391,23 @@ private:
|
|||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_block_info_by_height(uint64_t height)
|
||||
{
|
||||
std::list<currency::block_rpc_extended_info> blocks;
|
||||
bool r = m_srv.get_payload_object().get_core().get_blockchain_storage().get_main_blocks_rpc_details(height, 1, false, blocks);
|
||||
if (r && blocks.size())
|
||||
{
|
||||
currency::block_rpc_extended_info& rbei = blocks.back();
|
||||
LOG_PRINT_GREEN("------------------ block_id: " << rbei.id << " ------------------" << ENDL << epee::serialization::store_t_to_json(rbei), LOG_LEVEL_0);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_PRINT_GREEN("block wasn't found: " << height, LOG_LEVEL_0);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_block_by_hash(const std::string& arg)
|
||||
{
|
||||
crypto::hash block_hash;
|
||||
|
|
@ -443,6 +461,28 @@ private:
|
|||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_block_info(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty())
|
||||
{
|
||||
std::cout << "expected: print_block_info (<block_hash> | <block_height>)" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string& arg = args.front();
|
||||
try
|
||||
{
|
||||
uint64_t height = boost::lexical_cast<uint64_t>(arg);
|
||||
print_block_by_height(height);
|
||||
}
|
||||
catch (boost::bad_lexical_cast&)
|
||||
{
|
||||
print_block_by_hash(arg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_tx(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty())
|
||||
|
|
|
|||
|
|
@ -44,6 +44,13 @@ int main(int argc, char *argv[])
|
|||
|
||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER >= 1910
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
|
||||
qputenv("QT_SCALE_FACTOR", "0.75");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QApplication app(argc, argv);
|
||||
MainWindow viewer;
|
||||
if (!viewer.init_backend(argc, argv))
|
||||
|
|
|
|||
|
|
@ -1061,7 +1061,8 @@ namespace nodetool
|
|||
ce.time_started = cntxt.m_started;
|
||||
ce.last_recv = cntxt.m_last_recv;
|
||||
ce.last_send = cntxt.m_last_send;
|
||||
ce.version = cntxt.m_remote_version;
|
||||
std::strncpy(ce.version, cntxt.m_remote_version.c_str(), std::min(sizeof(ce.version), cntxt.m_remote_version.size()));
|
||||
ce.version[sizeof(ce.version) - 1] = 0; //null terminating just to be sure
|
||||
rsp.connections_list.push_back(ce);
|
||||
return true;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ namespace nodetool
|
|||
time_t last_seen;
|
||||
};
|
||||
|
||||
#define P2P_CONNECTION_ENTRY_VERSION_MAX_SIZE 50
|
||||
|
||||
struct connection_entry
|
||||
{
|
||||
net_address adr;
|
||||
|
|
@ -41,7 +43,7 @@ namespace nodetool
|
|||
uint64_t time_started;
|
||||
uint64_t last_recv;
|
||||
uint64_t last_send;
|
||||
std::string version;
|
||||
char version[P2P_CONNECTION_ENTRY_VERSION_MAX_SIZE];
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
|
|
|||
|
|
@ -1225,6 +1225,7 @@ namespace currency
|
|||
std::string cumulative_diff_precise;
|
||||
std::string difficulty;
|
||||
std::string prev_id;
|
||||
std::string pow_seed;
|
||||
uint64_t type;
|
||||
bool is_orphan;
|
||||
uint64_t already_generated_coins;
|
||||
|
|
@ -1249,6 +1250,7 @@ namespace currency
|
|||
KV_SERIALIZE(penalty)
|
||||
KV_SERIALIZE(id)
|
||||
KV_SERIALIZE(prev_id)
|
||||
KV_SERIALIZE(pow_seed)
|
||||
KV_SERIALIZE(cumulative_diff_adjusted)
|
||||
KV_SERIALIZE(cumulative_diff_precise)
|
||||
KV_SERIALIZE(difficulty)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue