Merge remote-tracking branch 'monero-official/master' into network-1.6-work1
This commit is contained in:
@@ -89,6 +89,7 @@ bool blockchain_storage::init(const std::string& config_folder, bool testnet)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
m_config_folder = config_folder;
|
||||
m_testnet = testnet;
|
||||
LOG_PRINT_L0("Loading blockchain...");
|
||||
const std::string filename = m_config_folder + "/" CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
|
||||
if(tools::unserialize_obj_from_file(*this, filename))
|
||||
@@ -1365,7 +1366,7 @@ bool blockchain_storage::pop_transaction_from_global_index(const transaction& tx
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::add_transaction_from_block(const transaction& tx, const crypto::hash& tx_id, const crypto::hash& bl_id, uint64_t bl_height)
|
||||
bool blockchain_storage::add_transaction_from_block(const transaction& tx, const crypto::hash& tx_id, const crypto::hash& bl_id, uint64_t bl_height, size_t blob_size)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
struct add_transaction_input_visitor: public boost::static_visitor<bool>
|
||||
@@ -1404,6 +1405,7 @@ bool blockchain_storage::add_transaction_from_block(const transaction& tx, const
|
||||
}
|
||||
transaction_chain_entry ch_e;
|
||||
ch_e.m_keeper_block_height = bl_height;
|
||||
ch_e.m_blob_size = blob_size;
|
||||
ch_e.tx = tx;
|
||||
auto i_r = m_transactions.insert(std::pair<crypto::hash, transaction_chain_entry>(tx_id, ch_e));
|
||||
if(!i_r.second)
|
||||
@@ -1669,10 +1671,12 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
||||
bvc.m_verifivation_failed = true;
|
||||
return false;
|
||||
}
|
||||
size_t coinbase_blob_size = get_object_blobsize(bl.miner_tx);
|
||||
crypto::hash coinbase_hash = null_hash;
|
||||
size_t coinbase_blob_size = 0;
|
||||
get_transaction_hash(bl.miner_tx, coinbase_hash, coinbase_blob_size);
|
||||
size_t cumulative_block_size = coinbase_blob_size;
|
||||
//process transactions
|
||||
if(!add_transaction_from_block(bl.miner_tx, get_transaction_hash(bl.miner_tx), id, get_current_blockchain_height()))
|
||||
if(!add_transaction_from_block(bl.miner_tx, coinbase_hash, id, get_current_blockchain_height(), coinbase_blob_size))
|
||||
{
|
||||
LOG_PRINT_L1("Block with id: " << id << " failed to add transaction to blockchain storage");
|
||||
bvc.m_verifivation_failed = true;
|
||||
@@ -1706,7 +1710,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!add_transaction_from_block(tx, tx_id, id, get_current_blockchain_height()))
|
||||
if(!add_transaction_from_block(tx, tx_id, id, get_current_blockchain_height(), blob_size))
|
||||
{
|
||||
LOG_PRINT_L1("Block with id: " << id << " failed to add transaction to blockchain storage");
|
||||
cryptonote::tx_verification_context tvc = AUTO_VAL_INIT(tvc);
|
||||
@@ -1736,7 +1740,14 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
||||
bei.bl = bl;
|
||||
bei.block_cumulative_size = cumulative_block_size;
|
||||
bei.cumulative_difficulty = current_diffic;
|
||||
bei.already_generated_coins = already_generated_coins + base_reward;
|
||||
|
||||
// In the "tail" state when the minimum subsidy (implemented in get_block_reward) is in effect, the number of
|
||||
// coins will eventually exceed MONEY_SUPPLY and overflow a uint64. To prevent overflow, cap already_generated_coins
|
||||
// at MONEY_SUPPLY. already_generated_coins is only used to compute the block subsidy and MONEY_SUPPLY yields a
|
||||
// subsidy of 0 under the base formula and therefore the minimum subsidy >0 in the tail state.
|
||||
|
||||
bei.already_generated_coins = base_reward < (MONEY_SUPPLY-already_generated_coins) ? already_generated_coins + base_reward : MONEY_SUPPLY;
|
||||
|
||||
if(m_blocks.size())
|
||||
bei.cumulative_difficulty += m_blocks.back().cumulative_difficulty;
|
||||
|
||||
@@ -1862,7 +1873,7 @@ bool blockchain_storage::update_checkpoints(const std::string& file_path, bool c
|
||||
else if (check_dns)
|
||||
{
|
||||
checkpoints dns_points;
|
||||
cryptonote::load_checkpoints_from_dns(dns_points);
|
||||
cryptonote::load_checkpoints_from_dns(dns_points, m_testnet);
|
||||
if (m_checkpoints.check_for_conflicts(dns_points))
|
||||
{
|
||||
check_against_checkpoints(dns_points, false);
|
||||
|
||||
Reference in New Issue
Block a user