2019-03-05 21:05:34 +00:00
|
|
|
// Copyright (c) 2014-2019, The Monero Project
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// All rights reserved.
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2015-12-14 04:54:39 +00:00
|
|
|
//
|
2014-07-23 13:03:52 +00:00
|
|
|
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
2014-03-03 22:07:58 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-09-25 05:15:28 +00:00
|
|
|
#include <ctime>
|
|
|
|
|
2014-03-03 22:07:58 +00:00
|
|
|
#include <boost/program_options/options_description.hpp>
|
|
|
|
#include <boost/program_options/variables_map.hpp>
|
|
|
|
|
|
|
|
#include "cryptonote_protocol/cryptonote_protocol_handler_common.h"
|
|
|
|
#include "storages/portable_storage_template_helper.h"
|
2017-02-26 21:00:38 +00:00
|
|
|
#include "common/download.h"
|
2017-10-28 15:06:43 +00:00
|
|
|
#include "common/command_line.h"
|
2014-03-03 22:07:58 +00:00
|
|
|
#include "tx_pool.h"
|
2014-10-28 03:44:45 +00:00
|
|
|
#include "blockchain.h"
|
2017-01-26 15:07:23 +00:00
|
|
|
#include "cryptonote_basic/miner.h"
|
|
|
|
#include "cryptonote_basic/connection_context.h"
|
|
|
|
#include "cryptonote_basic/cryptonote_stat_info.h"
|
2014-03-03 22:07:58 +00:00
|
|
|
#include "warnings.h"
|
|
|
|
#include "crypto/hash.h"
|
|
|
|
|
|
|
|
PUSH_WARNINGS
|
|
|
|
DISABLE_VS_WARNINGS(4355)
|
|
|
|
|
|
|
|
namespace cryptonote
|
|
|
|
{
|
2016-02-08 18:47:56 +00:00
|
|
|
struct test_options {
|
|
|
|
const std::pair<uint8_t, uint64_t> *hard_forks;
|
ArticMine's new block weight algorithm
This curbs runaway growth while still allowing substantial
spikes in block weight
Original specification from ArticMine:
here is the scaling proposal
Define: LongTermBlockWeight
Before fork:
LongTermBlockWeight = BlockWeight
At or after fork:
LongTermBlockWeight = min(BlockWeight, 1.4*LongTermEffectiveMedianBlockWeight)
Note: To avoid possible consensus issues over rounding the LongTermBlockWeight for a given block should be calculated to the nearest byte, and stored as a integer in the block itself. The stored LongTermBlockWeight is then used for future calculations of the LongTermEffectiveMedianBlockWeight and not recalculated each time.
Define: LongTermEffectiveMedianBlockWeight
LongTermEffectiveMedianBlockWeight = max(300000, MedianOverPrevious100000Blocks(LongTermBlockWeight))
Change Definition of EffectiveMedianBlockWeight
From (current definition)
EffectiveMedianBlockWeight = max(300000, MedianOverPrevious100Blocks(BlockWeight))
To (proposed definition)
EffectiveMedianBlockWeight = min(max(300000, MedianOverPrevious100Blocks(BlockWeight)), 50*LongTermEffectiveMedianBlockWeight)
Notes:
1) There are no other changes to the existing penalty formula, median calculation, fees etc.
2) There is the requirement to store the LongTermBlockWeight of a block unencrypted in the block itself. This is to avoid possible consensus issues over rounding and also to prevent the calculations from becoming unwieldy as we move away from the fork.
3) When the EffectiveMedianBlockWeight cap is reached it is still possible to mine blocks up to 2x the EffectiveMedianBlockWeight by paying the corresponding penalty.
Note: the long term block weight is stored in the database, but not in the actual block itself,
since it requires recalculating anyway for verification.
2019-01-21 17:18:50 +00:00
|
|
|
const size_t long_term_block_weight_window;
|
2016-02-08 18:47:56 +00:00
|
|
|
};
|
|
|
|
|
2018-02-16 11:04:04 +00:00
|
|
|
extern const command_line::arg_descriptor<std::string, false, true, 2> arg_data_dir;
|
2017-10-28 15:06:43 +00:00
|
|
|
extern const command_line::arg_descriptor<bool, false> arg_testnet_on;
|
2018-02-16 11:04:04 +00:00
|
|
|
extern const command_line::arg_descriptor<bool, false> arg_stagenet_on;
|
2018-06-14 19:11:49 +00:00
|
|
|
extern const command_line::arg_descriptor<bool, false> arg_regtest_on;
|
|
|
|
extern const command_line::arg_descriptor<difficulty_type> arg_fixed_difficulty;
|
2017-11-30 15:35:52 +00:00
|
|
|
extern const command_line::arg_descriptor<bool> arg_offline;
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 22:30:51 +00:00
|
|
|
extern const command_line::arg_descriptor<size_t> arg_block_download_max_size;
|
2017-10-28 15:06:43 +00:00
|
|
|
|
2014-03-03 22:07:58 +00:00
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief handles core cryptonote functionality
|
|
|
|
*
|
|
|
|
* This class coordinates cryptonote functionality including, but not
|
|
|
|
* limited to, communication among the Blockchain, the transaction pool,
|
|
|
|
* any miners, and the network.
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
class core: public i_miner_handler
|
|
|
|
{
|
|
|
|
public:
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief constructor
|
|
|
|
*
|
|
|
|
* sets member variables into a usable state
|
|
|
|
*
|
|
|
|
* @param pprotocol pre-constructed protocol object to store and use
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
core(i_cryptonote_protocol* pprotocol);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::handle_get_objects
|
|
|
|
*
|
|
|
|
* @note see Blockchain::handle_get_objects()
|
|
|
|
* @param context connection context associated with the request
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NOTIFY_RESPONSE_GET_OBJECTS::request& rsp, cryptonote_connection_context& context);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief calls various idle routines
|
|
|
|
*
|
|
|
|
* @note see miner::on_idle and tx_memory_pool::on_idle
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool on_idle();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief handles an incoming transaction
|
|
|
|
*
|
|
|
|
* Parses an incoming transaction and, if nothing is obviously wrong,
|
|
|
|
* passes it along to the transaction pool
|
|
|
|
*
|
|
|
|
* @param tx_blob the tx to handle
|
|
|
|
* @param tvc metadata about the transaction's validity
|
|
|
|
* @param keeped_by_block if the transaction has been in a block
|
|
|
|
* @param relayed whether or not the transaction was relayed to us
|
2017-01-14 13:01:21 +00:00
|
|
|
* @param do_not_relay whether to prevent the transaction from being relayed
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
2018-10-21 17:09:21 +00:00
|
|
|
* @return true if the transaction was accepted, false otherwise
|
2016-03-25 06:22:06 +00:00
|
|
|
*/
|
2017-01-14 13:01:21 +00:00
|
|
|
bool handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
2017-07-10 14:38:56 +00:00
|
|
|
/**
|
|
|
|
* @brief handles a list of incoming transactions
|
|
|
|
*
|
|
|
|
* Parses incoming transactions and, if nothing is obviously wrong,
|
|
|
|
* passes them along to the transaction pool
|
|
|
|
*
|
|
|
|
* @param tx_blobs the txs to handle
|
|
|
|
* @param tvc metadata about the transactions' validity
|
|
|
|
* @param keeped_by_block if the transactions have been in a block
|
|
|
|
* @param relayed whether or not the transactions were relayed to us
|
|
|
|
* @param do_not_relay whether to prevent the transactions from being relayed
|
|
|
|
*
|
2018-10-21 17:09:21 +00:00
|
|
|
* @return true if the transactions were accepted, false otherwise
|
2017-07-10 14:38:56 +00:00
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool handle_incoming_txs(const std::vector<blobdata>& tx_blobs, std::vector<tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
2017-07-10 14:38:56 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief handles an incoming block
|
|
|
|
*
|
|
|
|
* periodic update to checkpoints is triggered here
|
|
|
|
* Attempts to add the block to the Blockchain and, on success,
|
|
|
|
* optionally updates the miner's block template.
|
|
|
|
*
|
|
|
|
* @param block_blob the block to be added
|
2018-11-23 11:15:04 +00:00
|
|
|
* @param block the block to be added, or NULL
|
2016-03-25 06:22:06 +00:00
|
|
|
* @param bvc return-by-reference metadata context about the block's validity
|
|
|
|
* @param update_miner_blocktemplate whether or not to update the miner's block template
|
|
|
|
*
|
|
|
|
* @return false if loading new checkpoints fails, or the block is not
|
|
|
|
* added, otherwise true
|
|
|
|
*/
|
2018-11-23 11:15:04 +00:00
|
|
|
bool handle_incoming_block(const blobdata& block_blob, const block *b, block_verification_context& bvc, bool update_miner_blocktemplate = true);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::prepare_handle_incoming_blocks
|
|
|
|
*
|
|
|
|
* @note see Blockchain::prepare_handle_incoming_blocks
|
|
|
|
*/
|
2018-11-23 11:15:04 +00:00
|
|
|
bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
|
2015-10-08 02:28:51 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::cleanup_handle_incoming_blocks
|
|
|
|
*
|
|
|
|
* @note see Blockchain::cleanup_handle_incoming_blocks
|
|
|
|
*/
|
|
|
|
bool cleanup_handle_incoming_blocks(bool force_sync = false);
|
2016-10-10 20:41:24 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief check the size of a block against the current maximum
|
|
|
|
*
|
|
|
|
* @param block_blob the block to check
|
|
|
|
*
|
|
|
|
* @return whether or not the block is too big
|
|
|
|
*/
|
2016-03-25 06:42:42 +00:00
|
|
|
bool check_incoming_block_size(const blobdata& block_blob) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief get the cryptonote protocol instance
|
|
|
|
*
|
|
|
|
* @return the instance
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
i_cryptonote_protocol* get_protocol(){return m_pprotocol;}
|
|
|
|
|
|
|
|
//-------------------- i_miner_handler -----------------------
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief stores and relays a block found by a miner
|
|
|
|
*
|
|
|
|
* Updates the miner's target block, attempts to store the found
|
|
|
|
* block in Blockchain, and -- on success -- relays that block to
|
|
|
|
* the network.
|
|
|
|
*
|
|
|
|
* @param b the block found
|
|
|
|
*
|
|
|
|
* @return true if the block was added to the main chain, otherwise false
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
virtual bool handle_block_found( block& b);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::create_block_template
|
|
|
|
*
|
|
|
|
* @note see Blockchain::create_block_template
|
|
|
|
*/
|
2017-03-28 14:55:38 +00:00
|
|
|
virtual bool get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce);
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2016-10-22 19:46:51 +00:00
|
|
|
/**
|
|
|
|
* @brief called when a transaction is relayed
|
|
|
|
*/
|
|
|
|
virtual void on_transaction_relayed(const cryptonote::blobdata& tx);
|
|
|
|
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief gets the miner instance
|
|
|
|
*
|
|
|
|
* @return a reference to the miner instance
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
miner& get_miner(){return m_miner;}
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets the miner instance (const)
|
|
|
|
*
|
|
|
|
* @return a const reference to the miner instance
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
const miner& get_miner()const{return m_miner;}
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief adds command line options to the given options set
|
|
|
|
*
|
|
|
|
* As of now, there are no command line options specific to core,
|
|
|
|
* so this function simply returns.
|
|
|
|
*
|
|
|
|
* @param desc return-by-reference the command line options set to add to
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
static void init_options(boost::program_options::options_description& desc);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief initializes the core as needed
|
|
|
|
*
|
|
|
|
* This function initializes the transaction pool, the Blockchain, and
|
|
|
|
* a miner instance with parameters given on the command line (or defaults)
|
|
|
|
*
|
|
|
|
* @param vm command line parameters
|
|
|
|
* @param test_options configuration options for testing
|
2018-10-09 12:33:39 +00:00
|
|
|
* @param get_checkpoints if set, will be called to get checkpoints data, must return checkpoints data pointer and size or nullptr if there ain't any checkpoints for specific network type
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
|
|
|
* @return false if one of the init steps fails, otherwise true
|
|
|
|
*/
|
2018-11-23 13:47:51 +00:00
|
|
|
bool init(const boost::program_options::variables_map& vm, const test_options *test_options = NULL, const GetCheckpointsCallback& get_checkpoints = nullptr);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::reset_and_set_genesis_block
|
|
|
|
*
|
|
|
|
* @note see Blockchain::reset_and_set_genesis_block
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool set_genesis_block(const block& b);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief performs safe shutdown steps for core and core components
|
|
|
|
*
|
|
|
|
* Uninitializes the miner instance, transaction pool, and Blockchain
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool deinit();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief sets to drop blocks downloaded (for testing)
|
|
|
|
*/
|
2015-02-20 21:28:03 +00:00
|
|
|
void test_drop_download();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief sets to drop blocks downloaded below a certain height
|
|
|
|
*
|
|
|
|
* @param height height below which to drop blocks
|
|
|
|
*/
|
2015-02-20 21:28:03 +00:00
|
|
|
void test_drop_download_height(uint64_t height);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets whether or not to drop blocks (for testing)
|
|
|
|
*
|
|
|
|
* @return whether or not to drop blocks
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool get_test_drop_download() const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets whether or not to drop blocks
|
|
|
|
*
|
|
|
|
* If the current blockchain height <= our block drop threshold
|
|
|
|
* and test drop blocks is set, return true
|
|
|
|
*
|
|
|
|
* @return see above
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool get_test_drop_download_height() const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_current_blockchain_height
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_current_blockchain_height()
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
uint64_t get_current_blockchain_height() const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief get the hash and height of the most recent block
|
|
|
|
*
|
|
|
|
* @param height return-by-reference height of the block
|
|
|
|
* @param top_id return-by-reference hash of the block
|
|
|
|
*/
|
2017-09-09 11:06:24 +00:00
|
|
|
void get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-15 23:16:02 +00:00
|
|
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&, std::vector<transaction>&) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
2018-04-15 23:16:02 +00:00
|
|
|
* @note see Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&, std::vector<transaction>&) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks, std::vector<cryptonote::blobdata>& txs) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-15 23:16:02 +00:00
|
|
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
2018-04-15 23:16:02 +00:00
|
|
|
* @note see Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&) const
|
2017-01-15 16:05:55 +00:00
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks) const;
|
2017-01-15 16:05:55 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-15 23:16:02 +00:00
|
|
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&) const
|
2017-01-15 16:05:55 +00:00
|
|
|
*
|
2018-04-15 23:16:02 +00:00
|
|
|
* @note see Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_blocks(uint64_t start_offset, size_t count, std::vector<block>& blocks) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_blocks(const t_ids_container&, t_blocks_container&, t_missed_container&) const
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_blocks(const t_ids_container&, t_blocks_container&, t_missed_container&) const
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
template<class t_ids_container, class t_blocks_container, class t_missed_container>
|
2015-09-19 10:25:57 +00:00
|
|
|
bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs) const
|
2014-03-03 22:07:58 +00:00
|
|
|
{
|
|
|
|
return m_blockchain_storage.get_blocks(block_ids, blocks, missed_bs);
|
|
|
|
}
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_block_id_by_height
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_block_id_by_height
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
crypto::hash get_block_id_by_height(uint64_t height) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
2017-01-15 16:05:55 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_transactions
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_transactions
|
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs) const;
|
2017-01-15 16:05:55 +00:00
|
|
|
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 22:30:51 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_transactions
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_transactions
|
|
|
|
*/
|
|
|
|
bool get_split_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<std::tuple<crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata>>& txs, std::vector<crypto::hash>& missed_txs) const;
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_transactions
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_transactions
|
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_block_by_hash
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_block_by_hash
|
|
|
|
*/
|
2017-01-22 12:20:55 +00:00
|
|
|
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_alternative_blocks
|
|
|
|
*
|
2018-04-15 23:16:02 +00:00
|
|
|
* @note see Blockchain::get_alternative_blocks(std::vector<block>&) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_alternative_blocks(std::vector<block>& blocks) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_alternative_blocks_count
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_alternative_blocks_count() const
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
size_t get_alternative_blocks_count() const;
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief set the pointer to the cryptonote protocol object to use
|
|
|
|
*
|
|
|
|
* @param pprotocol the pointer to set ours as
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
void set_cryptonote_protocol(i_cryptonote_protocol* pprotocol);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::set_checkpoints
|
|
|
|
*
|
|
|
|
* @note see Blockchain::set_checkpoints()
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
void set_checkpoints(checkpoints&& chk_pts);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief set the file path to read from when loading checkpoints
|
|
|
|
*
|
|
|
|
* @param path the path to set ours as
|
|
|
|
*/
|
2014-09-25 05:15:28 +00:00
|
|
|
void set_checkpoints_file_path(const std::string& path);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief set whether or not we enforce DNS checkpoints
|
|
|
|
*
|
|
|
|
* @param enforce_dns enforce DNS checkpoints or not
|
|
|
|
*/
|
2014-09-26 05:01:58 +00:00
|
|
|
void set_enforce_dns_checkpoints(bool enforce_dns);
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2017-07-26 09:18:44 +00:00
|
|
|
/**
|
|
|
|
* @brief set whether or not to enable or disable DNS checkpoints
|
|
|
|
*
|
|
|
|
* @param disble whether to disable DNS checkpoints
|
|
|
|
*/
|
|
|
|
void disable_dns_checkpoints(bool disable = true) { m_disable_dns_checkpoints = disable; }
|
|
|
|
|
2017-05-14 13:06:55 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::have_tx
|
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::have_tx
|
|
|
|
*/
|
|
|
|
bool pool_has_tx(const crypto::hash &txid) const;
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_transactions
|
2017-11-08 12:06:41 +00:00
|
|
|
* @param include_unrelayed_txes include unrelayed txes in result
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_transactions
|
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
bool get_pool_transactions(std::vector<transaction>& txs, bool include_unrelayed_txes = true) const;
|
2017-11-08 12:06:41 +00:00
|
|
|
|
2017-08-26 15:23:31 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_txpool_backlog
|
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_txpool_backlog
|
|
|
|
*/
|
|
|
|
bool get_txpool_backlog(std::vector<tx_backlog_entry>& backlog) const;
|
|
|
|
|
2017-03-22 18:03:23 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_transactions
|
2017-11-08 12:06:41 +00:00
|
|
|
* @param include_unrelayed_txes include unrelayed txes in result
|
2017-03-22 18:03:23 +00:00
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_transactions
|
|
|
|
*/
|
2017-11-08 12:06:41 +00:00
|
|
|
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const;
|
2017-03-22 18:03:23 +00:00
|
|
|
|
2017-05-31 18:11:56 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_transactions
|
2017-11-08 12:06:41 +00:00
|
|
|
* @param include_unrelayed_txes include unrelayed txes in result
|
2017-05-31 18:11:56 +00:00
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_transactions
|
|
|
|
*/
|
2017-11-08 12:06:41 +00:00
|
|
|
bool get_pool_transaction_stats(struct txpool_stats& stats, bool include_unrelayed_txes = true) const;
|
2017-05-31 18:11:56 +00:00
|
|
|
|
2016-10-26 19:00:08 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_transaction
|
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_transaction
|
|
|
|
*/
|
2017-05-14 13:06:55 +00:00
|
|
|
bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_pool_transactions_and_spent_keys_info
|
2017-11-08 12:06:41 +00:00
|
|
|
* @param include_unrelayed_txes include unrelayed txes in result
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_pool_transactions_and_spent_keys_info
|
|
|
|
*/
|
2017-11-08 12:06:41 +00:00
|
|
|
bool get_pool_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos, bool include_unrelayed_txes = true) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
2017-09-05 16:20:27 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_pool_for_rpc
|
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_pool_for_rpc
|
|
|
|
*/
|
|
|
|
bool get_pool_for_rpc(std::vector<cryptonote::rpc::tx_in_pool>& tx_infos, cryptonote::rpc::key_images_with_tx_hashes& key_image_infos) const;
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::get_transactions_count
|
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::get_transactions_count
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
size_t get_pool_transactions_count() const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_total_transactions
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_total_transactions
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
size_t get_blockchain_total_transactions() const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::have_block
|
|
|
|
*
|
|
|
|
* @note see Blockchain::have_block
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool have_block(const crypto::hash& id) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_short_chain_history
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_short_chain_history
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool get_short_chain_history(std::list<crypto::hash>& ids) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::find_blockchain_supplement(const std::list<crypto::hash>&, NOTIFY_RESPONSE_CHAIN_ENTRY::request&) const
|
|
|
|
*
|
|
|
|
* @note see Blockchain::find_blockchain_supplement(const std::list<crypto::hash>&, NOTIFY_RESPONSE_CHAIN_ENTRY::request&) const
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-15 23:16:02 +00:00
|
|
|
* @copydoc Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::vector<std::pair<cryptonote::blobdata, std::vector<cryptonote::blobdata> > >&, uint64_t&, uint64_t&, size_t) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
2018-04-15 23:16:02 +00:00
|
|
|
* @note see Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::vector<std::pair<cryptonote::blobdata, std::vector<transaction> > >&, uint64_t&, uint64_t&, size_t) const
|
2016-03-25 06:22:06 +00:00
|
|
|
*/
|
2018-04-16 19:16:00 +00:00
|
|
|
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_count) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets some stats about the daemon
|
|
|
|
*
|
|
|
|
* @param st_inf return-by-reference container for the stats requested
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool get_stat_info(core_stat_info& st_inf) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_tx_outputs_gindexs
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_tx_outputs_gindexs
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<uint64_t>& indexs) const;
|
2018-12-16 13:28:49 +00:00
|
|
|
bool get_tx_outputs_gindexs(const crypto::hash& tx_id, size_t n_txes, std::vector<std::vector<uint64_t>>& indexs) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_tail_id
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_tail_id
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
crypto::hash get_tail_id() const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
2017-08-12 14:24:39 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_block_cumulative_difficulty
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_block_cumulative_difficulty
|
|
|
|
*/
|
|
|
|
difficulty_type get_block_cumulative_difficulty(uint64_t height) const;
|
|
|
|
|
2016-08-02 20:48:09 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_outs
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_outs
|
|
|
|
*/
|
2016-11-22 20:00:40 +00:00
|
|
|
bool get_outs(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res) const;
|
2016-08-02 20:48:09 +00:00
|
|
|
|
2018-02-19 11:15:15 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::get_output_distribution
|
|
|
|
*
|
|
|
|
* @brief get per block distribution of outputs of a given amount
|
|
|
|
*/
|
2018-05-16 21:41:50 +00:00
|
|
|
bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, uint64_t &start_height, std::vector<uint64_t> &distribution, uint64_t &base) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc miner::pause
|
|
|
|
*
|
|
|
|
* @note see miner::pause
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
void pause_mine();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc miner::resume
|
|
|
|
*
|
|
|
|
* @note see miner::resume
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
void resume_mine();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets the Blockchain instance
|
|
|
|
*
|
|
|
|
* @return a reference to the Blockchain instance
|
|
|
|
*/
|
2014-10-28 03:44:45 +00:00
|
|
|
Blockchain& get_blockchain_storage(){return m_blockchain_storage;}
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets the Blockchain instance (const)
|
|
|
|
*
|
|
|
|
* @return a const reference to the Blockchain instance
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
const Blockchain& get_blockchain_storage()const{return m_blockchain_storage;}
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc tx_memory_pool::print_pool
|
|
|
|
*
|
|
|
|
* @note see tx_memory_pool::print_pool
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
std::string print_pool(bool short_format) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc miner::on_synchronized
|
|
|
|
*
|
|
|
|
* @note see miner::on_synchronized
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
void on_synchronized();
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
2017-08-22 13:54:18 +00:00
|
|
|
* @copydoc Blockchain::safesyncmode
|
|
|
|
*
|
|
|
|
* 2note see Blockchain::safesyncmode
|
|
|
|
*/
|
|
|
|
void safesyncmode(const bool onoff);
|
|
|
|
|
|
|
|
/**
|
2016-03-25 06:22:06 +00:00
|
|
|
* @brief sets the target blockchain height
|
|
|
|
*
|
|
|
|
* @param target_blockchain_height the height to set
|
|
|
|
*/
|
2014-06-04 20:50:13 +00:00
|
|
|
void set_target_blockchain_height(uint64_t target_blockchain_height);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief gets the target blockchain height
|
|
|
|
*
|
|
|
|
* @param target_blockchain_height the target height
|
|
|
|
*/
|
2014-06-04 20:50:13 +00:00
|
|
|
uint64_t get_target_blockchain_height() const;
|
|
|
|
|
2018-04-16 02:02:26 +00:00
|
|
|
/**
|
|
|
|
* @brief returns the newest hardfork version known to the blockchain
|
|
|
|
*
|
|
|
|
* @return the version
|
|
|
|
*/
|
|
|
|
uint8_t get_ideal_hard_fork_version() const;
|
|
|
|
|
2017-08-10 09:10:04 +00:00
|
|
|
/**
|
|
|
|
* @brief return the ideal hard fork version for a given block height
|
|
|
|
*
|
|
|
|
* @return what it says above
|
|
|
|
*/
|
|
|
|
uint8_t get_ideal_hard_fork_version(uint64_t height) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief return the hard fork version for a given block height
|
|
|
|
*
|
|
|
|
* @return what it says above
|
|
|
|
*/
|
|
|
|
uint8_t get_hard_fork_version(uint64_t height) const;
|
|
|
|
|
2018-03-20 11:30:09 +00:00
|
|
|
/**
|
|
|
|
* @brief return the earliest block a given version may activate
|
|
|
|
*
|
|
|
|
* @return what it says above
|
|
|
|
*/
|
|
|
|
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const;
|
|
|
|
|
2017-01-08 23:50:29 +00:00
|
|
|
/**
|
|
|
|
* @brief gets start_time
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
std::time_t get_start_time() const;
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief tells the Blockchain to update its checkpoints
|
|
|
|
*
|
|
|
|
* This function will check if enough time has passed since the last
|
|
|
|
* time checkpoints were updated and tell the Blockchain to update
|
|
|
|
* its checkpoints if it is time. If updating checkpoints fails,
|
|
|
|
* the daemon is told to shut down.
|
|
|
|
*
|
|
|
|
* @note see Blockchain::update_checkpoints()
|
|
|
|
*/
|
2014-09-26 05:01:58 +00:00
|
|
|
bool update_checkpoints();
|
2014-09-25 05:15:28 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief tells the daemon to wind down operations and stop running
|
|
|
|
*
|
|
|
|
* Currently this function raises SIGTERM, allowing the installed signal
|
|
|
|
* handlers to do the actual stopping.
|
|
|
|
*/
|
|
|
|
void graceful_exit();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief stops the daemon running
|
|
|
|
*
|
|
|
|
* @note see graceful_exit()
|
|
|
|
*/
|
2015-02-05 09:11:20 +00:00
|
|
|
void stop();
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::have_tx_keyimg_as_spent
|
|
|
|
*
|
|
|
|
* @note see Blockchain::have_tx_keyimg_as_spent
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool is_key_image_spent(const crypto::key_image& key_im) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief check if multiple key images are spent
|
|
|
|
*
|
|
|
|
* plural version of is_key_image_spent()
|
|
|
|
*
|
|
|
|
* @param key_im list of key images to check
|
|
|
|
* @param spent return-by-reference result for each image checked
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool are_key_images_spent(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
|
2015-08-11 09:49:15 +00:00
|
|
|
|
2016-09-24 16:00:19 +00:00
|
|
|
/**
|
2017-09-05 16:20:27 +00:00
|
|
|
* @brief check if multiple key images are spent in the transaction pool
|
|
|
|
*
|
|
|
|
* @param key_im list of key images to check
|
|
|
|
* @param spent return-by-reference result for each image checked
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
|
|
|
bool are_key_images_spent_in_pool(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
|
|
|
|
|
2016-09-24 16:00:19 +00:00
|
|
|
/**
|
|
|
|
* @brief get the number of blocks to sync in one go
|
|
|
|
*
|
|
|
|
* @return the number of blocks to sync in one go
|
|
|
|
*/
|
2017-08-16 20:19:53 +00:00
|
|
|
size_t get_block_sync_size(uint64_t height) const;
|
2016-09-24 16:00:19 +00:00
|
|
|
|
2016-10-10 19:45:51 +00:00
|
|
|
/**
|
|
|
|
* @brief get the sum of coinbase tx amounts between blocks
|
|
|
|
*
|
|
|
|
* @return the number of blocks to sync in one go
|
|
|
|
*/
|
2016-10-13 16:49:25 +00:00
|
|
|
std::pair<uint64_t, uint64_t> get_coinbase_tx_sum(const uint64_t start_offset, const size_t count);
|
2016-10-26 19:00:08 +00:00
|
|
|
|
|
|
|
/**
|
2018-02-16 11:04:04 +00:00
|
|
|
* @brief get the network type we're on
|
2016-10-26 19:00:08 +00:00
|
|
|
*
|
2018-02-16 11:04:04 +00:00
|
|
|
* @return which network are we on?
|
2016-10-26 19:00:08 +00:00
|
|
|
*/
|
2018-02-16 11:04:04 +00:00
|
|
|
network_type get_nettype() const { return m_nettype; };
|
2016-10-10 19:45:51 +00:00
|
|
|
|
2018-06-18 14:31:34 +00:00
|
|
|
/**
|
|
|
|
* @brief check whether an update is known to be available or not
|
|
|
|
*
|
|
|
|
* This does not actually trigger a check, but returns the result
|
|
|
|
* of the last check
|
|
|
|
*
|
|
|
|
* @return whether an update is known to be available or not
|
|
|
|
*/
|
|
|
|
bool is_update_available() const { return m_update_available; }
|
|
|
|
|
2017-09-02 16:11:20 +00:00
|
|
|
/**
|
|
|
|
* @brief get whether fluffy blocks are enabled
|
|
|
|
*
|
|
|
|
* @return whether fluffy blocks are enabled
|
|
|
|
*/
|
|
|
|
bool fluffy_blocks_enabled() const { return m_fluffy_blocks_enabled; }
|
|
|
|
|
2018-11-02 22:27:25 +00:00
|
|
|
/**
|
|
|
|
* @brief get whether transaction relay should be padded
|
|
|
|
*
|
|
|
|
* @return whether transaction relay should be padded
|
|
|
|
*/
|
|
|
|
bool pad_transactions() const { return m_pad_transactions; }
|
|
|
|
|
2017-09-13 20:03:04 +00:00
|
|
|
/**
|
|
|
|
* @brief check a set of hashes against the precompiled hash set
|
|
|
|
*
|
|
|
|
* @return number of usable blocks
|
|
|
|
*/
|
2018-04-15 23:16:02 +00:00
|
|
|
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes);
|
2017-09-13 20:03:04 +00:00
|
|
|
|
2017-11-11 23:25:12 +00:00
|
|
|
/**
|
|
|
|
* @brief get free disk space on the blockchain partition
|
|
|
|
*
|
|
|
|
* @return free space in bytes
|
|
|
|
*/
|
|
|
|
uint64_t get_free_space() const;
|
|
|
|
|
2017-11-30 15:35:52 +00:00
|
|
|
/**
|
|
|
|
* @brief get whether the core is running offline
|
|
|
|
*
|
|
|
|
* @return whether the core is running offline
|
|
|
|
*/
|
|
|
|
bool offline() const { return m_offline; }
|
|
|
|
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 22:30:51 +00:00
|
|
|
/**
|
|
|
|
* @brief get the blockchain pruning seed
|
|
|
|
*
|
|
|
|
* @return the blockchain pruning seed
|
|
|
|
*/
|
|
|
|
uint32_t get_blockchain_pruning_seed() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief prune the blockchain
|
|
|
|
*
|
|
|
|
* @param pruning_seed the seed to use to prune the chain (0 for default, highly recommended)
|
|
|
|
*
|
|
|
|
* @return true iff success
|
|
|
|
*/
|
|
|
|
bool prune_blockchain(uint32_t pruning_seed = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief incrementally prunes blockchain
|
|
|
|
*
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
bool update_blockchain_pruning();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief checks the blockchain pruning if enabled
|
|
|
|
*
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
bool check_blockchain_pruning();
|
|
|
|
|
2014-09-26 05:01:58 +00:00
|
|
|
private:
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-14 13:06:55 +00:00
|
|
|
* @copydoc add_new_tx(transaction&, tx_verification_context&, bool)
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
|
|
|
* @param tx_hash the transaction's hash
|
2018-10-31 08:31:13 +00:00
|
|
|
* @param blob the transaction as a blob
|
2018-07-18 21:24:53 +00:00
|
|
|
* @param tx_weight the weight of the transaction
|
2016-03-25 06:22:06 +00:00
|
|
|
* @param relayed whether or not the transaction was relayed to us
|
2017-01-14 13:01:21 +00:00
|
|
|
* @param do_not_relay whether to prevent the transaction from being relayed
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
|
|
|
*/
|
2018-11-12 23:22:20 +00:00
|
|
|
bool add_new_tx(transaction& tx, const crypto::hash& tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief add a new transaction to the transaction pool
|
|
|
|
*
|
|
|
|
* Adds a new transaction to the transaction pool.
|
|
|
|
*
|
|
|
|
* @param tx the transaction to add
|
|
|
|
* @param tvc return-by-reference metadata about the transaction's verification process
|
|
|
|
* @param keeped_by_block whether or not the transaction has been in a block
|
|
|
|
* @param relayed whether or not the transaction was relayed to us
|
2017-01-14 13:01:21 +00:00
|
|
|
* @param do_not_relay whether to prevent the transaction from being relayed
|
2016-03-25 06:22:06 +00:00
|
|
|
*
|
|
|
|
* @return true if the transaction is already in the transaction pool,
|
|
|
|
* is already in a block on the Blockchain, or is successfully added
|
|
|
|
* to the transaction pool
|
|
|
|
*/
|
2017-05-14 13:06:55 +00:00
|
|
|
bool add_new_tx(transaction& tx, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc Blockchain::add_new_block
|
|
|
|
*
|
|
|
|
* @note see Blockchain::add_new_block
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool add_new_block(const block& b, block_verification_context& bvc);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief load any core state stored on disk
|
|
|
|
*
|
|
|
|
* currently does nothing, but may have state to load in the future.
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool load_state_data();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc parse_tx_from_blob(transaction&, crypto::hash&, crypto::hash&, const blobdata&) const
|
|
|
|
*
|
|
|
|
* @note see parse_tx_from_blob(transaction&, crypto::hash&, crypto::hash&, const blobdata&) const
|
|
|
|
*/
|
2018-11-12 23:22:20 +00:00
|
|
|
bool parse_tx_from_blob(transaction& tx, crypto::hash& tx_hash, const blobdata& blob) const;
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief check a transaction's syntax
|
|
|
|
*
|
|
|
|
* For now this does nothing, but it may check something about the tx
|
|
|
|
* in the future.
|
|
|
|
*
|
|
|
|
* @param tx the transaction to check
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool check_tx_syntax(const transaction& tx) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief validates some simple properties of a transaction
|
|
|
|
*
|
|
|
|
* Currently checks: tx has inputs,
|
|
|
|
* tx inputs all of supported type(s),
|
|
|
|
* tx outputs valid (type, key, amount),
|
|
|
|
* input and output total amounts don't overflow,
|
|
|
|
* output amount <= input amount,
|
|
|
|
* tx not too large,
|
|
|
|
* each input has a different key image.
|
|
|
|
*
|
|
|
|
* @param tx the transaction to check
|
|
|
|
* @param keeped_by_block if the transaction has been in a block
|
|
|
|
*
|
|
|
|
* @return true if all the checks pass, otherwise false
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool check_tx_semantic(const transaction& tx, bool keeped_by_block) const;
|
2018-03-30 19:29:42 +00:00
|
|
|
void set_semantics_failed(const crypto::hash &tx_hash);
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2018-11-12 23:22:20 +00:00
|
|
|
bool handle_incoming_tx_pre(const blobdata& tx_blob, tx_verification_context& tvc, cryptonote::transaction &tx, crypto::hash &tx_hash, bool keeped_by_block, bool relayed, bool do_not_relay);
|
|
|
|
bool handle_incoming_tx_post(const blobdata& tx_blob, tx_verification_context& tvc, cryptonote::transaction &tx, crypto::hash &tx_hash, bool keeped_by_block, bool relayed, bool do_not_relay);
|
2018-03-30 19:29:42 +00:00
|
|
|
struct tx_verification_batch_info { const cryptonote::transaction *tx; crypto::hash tx_hash; tx_verification_context &tvc; bool &result; };
|
|
|
|
bool handle_incoming_tx_accumulated_batch(std::vector<tx_verification_batch_info> &tx_info, bool keeped_by_block);
|
2017-07-10 14:38:56 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @copydoc miner::on_block_chain_update
|
|
|
|
*
|
|
|
|
* @note see miner::on_block_chain_update
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2014-03-03 22:07:58 +00:00
|
|
|
bool update_miner_block_template();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief act on a set of command line options given
|
|
|
|
*
|
|
|
|
* @param vm the command line options
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2015-01-29 22:10:53 +00:00
|
|
|
bool handle_command_line(const boost::program_options::variables_map& vm);
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief verify that each input key image in a transaction is unique
|
|
|
|
*
|
|
|
|
* @param tx the transaction to check
|
|
|
|
*
|
|
|
|
* @return false if any key image is repeated, otherwise true
|
|
|
|
*/
|
2015-09-19 10:25:57 +00:00
|
|
|
bool check_tx_inputs_keyimages_diff(const transaction& tx) const;
|
2016-03-25 06:22:06 +00:00
|
|
|
|
2017-07-18 21:38:26 +00:00
|
|
|
/**
|
|
|
|
* @brief verify that each ring uses distinct members
|
|
|
|
*
|
|
|
|
* @param tx the transaction to check
|
|
|
|
*
|
|
|
|
* @return false if any ring uses duplicate members, true otherwise
|
|
|
|
*/
|
|
|
|
bool check_tx_inputs_ring_members_diff(const transaction& tx) const;
|
|
|
|
|
2017-02-20 17:41:39 +00:00
|
|
|
/**
|
|
|
|
* @brief verify that each input key image in a transaction is in
|
|
|
|
* the valid domain
|
|
|
|
*
|
|
|
|
* @param tx the transaction to check
|
|
|
|
*
|
|
|
|
* @return false if any key image is not in the valid domain, otherwise true
|
|
|
|
*/
|
|
|
|
bool check_tx_inputs_keyimages_domain(const transaction& tx) const;
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
/**
|
|
|
|
* @brief checks HardFork status and prints messages about it
|
|
|
|
*
|
|
|
|
* Checks the status of HardFork and logs/prints if an update to
|
|
|
|
* the daemon is necessary.
|
|
|
|
*
|
|
|
|
* @note see Blockchain::get_hard_fork_state and HardFork::State
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2015-09-13 17:09:57 +00:00
|
|
|
bool check_fork_time();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief attempts to relay any transactions in the mempool which need it
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
*/
|
2015-11-21 00:26:48 +00:00
|
|
|
bool relay_txpool_transactions();
|
2016-03-25 06:22:06 +00:00
|
|
|
|
2017-02-18 16:30:29 +00:00
|
|
|
/**
|
|
|
|
* @brief checks DNS versions
|
|
|
|
*
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
bool check_updates();
|
|
|
|
|
2017-11-11 23:25:12 +00:00
|
|
|
/**
|
|
|
|
* @brief checks free disk space
|
|
|
|
*
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
bool check_disk_space();
|
|
|
|
|
2018-09-20 13:31:45 +00:00
|
|
|
/**
|
|
|
|
* @brief checks block rate, and warns if it's too slow
|
|
|
|
*
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
bool check_block_rate();
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
bool m_test_drop_download = true; //!< whether or not to drop incoming blocks (for testing)
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
uint64_t m_test_drop_download_height = 0; //!< height under which to drop incoming blocks, if doing so
|
|
|
|
|
|
|
|
tx_memory_pool m_mempool; //!< transaction pool instance
|
|
|
|
Blockchain m_blockchain_storage; //!< Blockchain instance
|
|
|
|
|
|
|
|
i_cryptonote_protocol* m_pprotocol; //!< cryptonote protocol instance
|
|
|
|
|
|
|
|
epee::critical_section m_incoming_tx_lock; //!< incoming transaction lock
|
|
|
|
|
2014-03-03 22:07:58 +00:00
|
|
|
//m_miner and m_miner_addres are probably temporary here
|
2016-03-25 06:22:06 +00:00
|
|
|
miner m_miner; //!< miner instance
|
|
|
|
account_public_address m_miner_address; //!< address to mine to (for miner instance)
|
|
|
|
|
|
|
|
std::string m_config_folder; //!< folder to look in for configs and other files
|
|
|
|
|
|
|
|
cryptonote_protocol_stub m_protocol_stub; //!< cryptonote protocol stub instance
|
|
|
|
|
|
|
|
epee::math_helper::once_a_time_seconds<60*60*12, false> m_store_blockchain_interval; //!< interval for manual storing of Blockchain, if enabled
|
2017-02-16 23:46:42 +00:00
|
|
|
epee::math_helper::once_a_time_seconds<60*60*2, true> m_fork_moaner; //!< interval for checking HardFork status
|
2015-11-21 00:26:48 +00:00
|
|
|
epee::math_helper::once_a_time_seconds<60*2, false> m_txpool_auto_relayer; //!< interval for checking re-relaying txpool transactions
|
2017-02-18 16:30:29 +00:00
|
|
|
epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions
|
2017-11-11 23:25:12 +00:00
|
|
|
epee::math_helper::once_a_time_seconds<60*10, true> m_check_disk_space_interval; //!< interval for checking for disk space
|
2018-09-20 13:31:45 +00:00
|
|
|
epee::math_helper::once_a_time_seconds<90, false> m_block_rate_interval; //!< interval for checking block rate
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 22:30:51 +00:00
|
|
|
epee::math_helper::once_a_time_seconds<60*60*5, true> m_blockchain_pruning_interval; //!< interval for incremental blockchain pruning
|
2016-03-25 06:22:06 +00:00
|
|
|
|
|
|
|
std::atomic<bool> m_starter_message_showed; //!< has the "daemon will sync now" message been shown?
|
|
|
|
|
|
|
|
uint64_t m_target_blockchain_height; //!< blockchain height target
|
|
|
|
|
2018-02-16 11:04:04 +00:00
|
|
|
network_type m_nettype; //!< which network are we on?
|
2014-09-25 05:15:28 +00:00
|
|
|
|
2018-06-18 14:31:34 +00:00
|
|
|
std::atomic<bool> m_update_available;
|
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
std::string m_checkpoints_path; //!< path to json checkpoints file
|
|
|
|
time_t m_last_dns_checkpoints_update; //!< time when dns checkpoints were last updated
|
|
|
|
time_t m_last_json_checkpoints_update; //!< time when json checkpoints were last updated
|
2015-04-22 08:36:39 +00:00
|
|
|
|
2016-03-25 06:22:06 +00:00
|
|
|
std::atomic_flag m_checkpoints_updating; //!< set if checkpoints are currently updating to avoid multiple threads attempting to update at once
|
2017-07-26 09:18:44 +00:00
|
|
|
bool m_disable_dns_checkpoints;
|
2016-01-31 12:58:08 +00:00
|
|
|
|
2016-09-24 16:00:19 +00:00
|
|
|
size_t block_sync_size;
|
2017-01-08 23:50:29 +00:00
|
|
|
|
|
|
|
time_t start_time;
|
2017-01-22 16:13:31 +00:00
|
|
|
|
2017-02-23 20:15:52 +00:00
|
|
|
std::unordered_set<crypto::hash> bad_semantics_txes[2];
|
2017-07-10 14:38:56 +00:00
|
|
|
boost::mutex bad_semantics_txes_lock;
|
|
|
|
|
2017-02-18 16:30:29 +00:00
|
|
|
enum {
|
|
|
|
UPDATES_DISABLED,
|
|
|
|
UPDATES_NOTIFY,
|
|
|
|
UPDATES_DOWNLOAD,
|
|
|
|
UPDATES_UPDATE,
|
|
|
|
} check_updates_level;
|
2017-02-26 21:00:38 +00:00
|
|
|
|
|
|
|
tools::download_async_handle m_update_download;
|
|
|
|
size_t m_last_update_length;
|
|
|
|
boost::mutex m_update_mutex;
|
2017-09-02 16:11:20 +00:00
|
|
|
|
|
|
|
bool m_fluffy_blocks_enabled;
|
2017-11-30 15:35:52 +00:00
|
|
|
bool m_offline;
|
2018-11-02 22:27:25 +00:00
|
|
|
bool m_pad_transactions;
|
2019-02-06 17:09:28 +00:00
|
|
|
|
|
|
|
std::shared_ptr<tools::Notify> m_block_rate_notify;
|
2014-03-03 22:07:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
POP_WARNINGS
|