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.
This commit is contained in:
@@ -105,6 +105,11 @@ namespace cryptonote
|
||||
"disable-dns-checkpoints"
|
||||
, "Do not retrieve checkpoints from DNS"
|
||||
};
|
||||
const command_line::arg_descriptor<size_t> arg_block_download_max_size = {
|
||||
"block-download-max-size"
|
||||
, "Set maximum size of block download queue in bytes (0 for default)"
|
||||
, 0
|
||||
};
|
||||
|
||||
static const command_line::arg_descriptor<bool> arg_test_drop_download = {
|
||||
"test-drop-download"
|
||||
@@ -175,6 +180,11 @@ namespace cryptonote
|
||||
, "Run a program for each new block, '%s' will be replaced by the block hash"
|
||||
, ""
|
||||
};
|
||||
static const command_line::arg_descriptor<bool> arg_prune_blockchain = {
|
||||
"prune-blockchain"
|
||||
, "Prune blockchain"
|
||||
, false
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
core::core(i_cryptonote_protocol* pprotocol):
|
||||
@@ -285,9 +295,11 @@ namespace cryptonote
|
||||
command_line::add_arg(desc, arg_test_dbg_lock_sleep);
|
||||
command_line::add_arg(desc, arg_offline);
|
||||
command_line::add_arg(desc, arg_disable_dns_checkpoints);
|
||||
command_line::add_arg(desc, arg_block_download_max_size);
|
||||
command_line::add_arg(desc, arg_max_txpool_weight);
|
||||
command_line::add_arg(desc, arg_pad_transactions);
|
||||
command_line::add_arg(desc, arg_block_notify);
|
||||
command_line::add_arg(desc, arg_prune_blockchain);
|
||||
|
||||
miner::init_options(desc);
|
||||
BlockchainDB::init_options(desc);
|
||||
@@ -374,6 +386,11 @@ namespace cryptonote
|
||||
return m_blockchain_storage.get_transactions_blobs(txs_ids, txs, missed_txs);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::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
|
||||
{
|
||||
return m_blockchain_storage.get_split_transactions_blobs(txs_ids, txs, missed_txs);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::get_txpool_backlog(std::vector<tx_backlog_entry>& backlog) const
|
||||
{
|
||||
m_mempool.get_transaction_backlog(backlog);
|
||||
@@ -413,6 +430,7 @@ namespace cryptonote
|
||||
uint64_t blocks_threads = command_line::get_arg(vm, arg_prep_blocks_threads);
|
||||
std::string check_updates_string = command_line::get_arg(vm, arg_check_updates);
|
||||
size_t max_txpool_weight = command_line::get_arg(vm, arg_max_txpool_weight);
|
||||
bool prune_blockchain = command_line::get_arg(vm, arg_prune_blockchain);
|
||||
|
||||
boost::filesystem::path folder(m_config_folder);
|
||||
if (m_nettype == FAKECHAIN)
|
||||
@@ -607,6 +625,14 @@ namespace cryptonote
|
||||
r = m_miner.init(vm, m_nettype);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize miner instance");
|
||||
|
||||
if (prune_blockchain)
|
||||
{
|
||||
// display a message if the blockchain is not pruned yet
|
||||
if (m_blockchain_storage.get_current_blockchain_height() > 1 && !m_blockchain_storage.get_blockchain_pruning_seed())
|
||||
MGINFO("Pruning blockchain...");
|
||||
CHECK_AND_ASSERT_MES(m_blockchain_storage.prune_blockchain(), false, "Failed to prune blockchain");
|
||||
}
|
||||
|
||||
return load_state_data();
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@@ -1501,6 +1527,7 @@ namespace cryptonote
|
||||
m_check_updates_interval.do_call(boost::bind(&core::check_updates, this));
|
||||
m_check_disk_space_interval.do_call(boost::bind(&core::check_disk_space, this));
|
||||
m_block_rate_interval.do_call(boost::bind(&core::check_block_rate, this));
|
||||
m_blockchain_pruning_interval.do_call(boost::bind(&core::update_blockchain_pruning, this));
|
||||
m_miner.on_idle();
|
||||
m_mempool.on_idle();
|
||||
return true;
|
||||
@@ -1736,6 +1763,16 @@ namespace cryptonote
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::update_blockchain_pruning()
|
||||
{
|
||||
return m_blockchain_storage.update_blockchain_pruning();
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::check_blockchain_pruning()
|
||||
{
|
||||
return m_blockchain_storage.check_blockchain_pruning();
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void core::set_target_blockchain_height(uint64_t target_blockchain_height)
|
||||
{
|
||||
m_target_blockchain_height = target_blockchain_height;
|
||||
@@ -1758,6 +1795,16 @@ namespace cryptonote
|
||||
return si.available;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
uint32_t core::get_blockchain_pruning_seed() const
|
||||
{
|
||||
return get_blockchain_storage().get_blockchain_pruning_seed();
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::prune_blockchain(uint32_t pruning_seed)
|
||||
{
|
||||
return get_blockchain_storage().prune_blockchain(pruning_seed);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
std::time_t core::get_start_time() const
|
||||
{
|
||||
return start_time;
|
||||
|
||||
Reference in New Issue
Block a user