mirror of
https://github.com/monero-project/monero.git
synced 2025-08-13 22:45:36 -04:00
Merge pull request #4333
73403004
add --block-notify to monerod and --tx-notify to monero-wallet-{cli,rpc} (moneromooo-monero)
This commit is contained in:
parent
4a2664f743
commit
83d8f03c23
10 changed files with 300 additions and 0 deletions
|
@ -52,6 +52,7 @@
|
|||
#include "cryptonote_core.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "common/perf_timer.h"
|
||||
#include "common/notify.h"
|
||||
#if defined(PER_BLOCK_CHECKPOINT)
|
||||
#include "blocks/blocks.h"
|
||||
#endif
|
||||
|
@ -3552,6 +3553,10 @@ leave:
|
|||
get_difficulty_for_next_block(); // just to cache it
|
||||
invalidate_block_template_cache();
|
||||
|
||||
std::shared_ptr<tools::Notify> block_notify = m_block_notify;
|
||||
if (block_notify)
|
||||
block_notify->notify(epee::string_tools::pod_to_hex(id).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#include "cryptonote_basic/hardfork.h"
|
||||
#include "blockchain_db/blockchain_db.h"
|
||||
|
||||
namespace tools { class Notify; }
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
class tx_memory_pool;
|
||||
|
@ -705,6 +707,13 @@ namespace cryptonote
|
|||
void set_user_options(uint64_t maxthreads, bool sync_on_blocks, uint64_t sync_threshold,
|
||||
blockchain_db_sync_mode sync_mode, bool fast_sync);
|
||||
|
||||
/**
|
||||
* @brief sets a block notify object to call for every new block
|
||||
*
|
||||
* @param notify the notify object to cal at every new block
|
||||
*/
|
||||
void set_block_notify(const std::shared_ptr<tools::Notify> ¬ify) { m_block_notify = notify; }
|
||||
|
||||
/**
|
||||
* @brief Put DB in safe sync mode
|
||||
*/
|
||||
|
@ -1032,6 +1041,8 @@ namespace cryptonote
|
|||
uint64_t m_btc_expected_reward;
|
||||
bool m_btc_valid;
|
||||
|
||||
std::shared_ptr<tools::Notify> m_block_notify;
|
||||
|
||||
/**
|
||||
* @brief collects the keys for all outputs being "spent" as an input
|
||||
*
|
||||
|
|
|
@ -53,6 +53,7 @@ using namespace epee;
|
|||
#include "ringct/rctTypes.h"
|
||||
#include "blockchain_db/blockchain_db.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "common/notify.h"
|
||||
#include "version.h"
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
|
@ -167,6 +168,11 @@ namespace cryptonote
|
|||
, "Set maximum txpool weight in bytes."
|
||||
, DEFAULT_TXPOOL_MAX_WEIGHT
|
||||
};
|
||||
static const command_line::arg_descriptor<std::string> arg_block_notify = {
|
||||
"block-notify"
|
||||
, "Run a program for each new block, '%s' will be replaced by the block hash"
|
||||
, ""
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
core::core(i_cryptonote_protocol* pprotocol):
|
||||
|
@ -276,6 +282,7 @@ namespace cryptonote
|
|||
command_line::add_arg(desc, arg_offline);
|
||||
command_line::add_arg(desc, arg_disable_dns_checkpoints);
|
||||
command_line::add_arg(desc, arg_max_txpool_weight);
|
||||
command_line::add_arg(desc, arg_block_notify);
|
||||
|
||||
miner::init_options(desc);
|
||||
BlockchainDB::init_options(desc);
|
||||
|
@ -545,6 +552,16 @@ namespace cryptonote
|
|||
m_blockchain_storage.set_user_options(blocks_threads,
|
||||
sync_on_blocks, sync_threshold, sync_mode, fast_sync);
|
||||
|
||||
try
|
||||
{
|
||||
if (!command_line::is_arg_defaulted(vm, arg_block_notify))
|
||||
m_blockchain_storage.set_block_notify(std::shared_ptr<tools::Notify>(new tools::Notify(command_line::get_arg(vm, arg_block_notify).c_str())));
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
MERROR("Failed to parse block notify spec");
|
||||
}
|
||||
|
||||
const std::pair<uint8_t, uint64_t> regtest_hard_forks[3] = {std::make_pair(1, 0), std::make_pair(Blockchain::get_hard_fork_heights(MAINNET).back().version, 1), std::make_pair(0, 0)};
|
||||
const cryptonote::test_options regtest_test_options = {
|
||||
regtest_hard_forks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue