Merge upstream into blockchain

This commit is contained in:
Thomas Winget 2015-03-29 09:58:18 -04:00
commit 94cb295db4
No known key found for this signature in database
GPG key ID: 58131A160789E630
7 changed files with 143 additions and 29 deletions

View file

@ -1329,7 +1329,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>
@ -1368,6 +1368,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)
@ -1633,10 +1634,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;
@ -1670,7 +1673,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);

View file

@ -239,7 +239,7 @@ namespace cryptonote
bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins) const;
bool validate_transaction(const block& b, uint64_t height, const transaction& tx) const;
bool rollback_blockchain_switching(std::list<block>& original_chain, size_t rollback_height);
bool add_transaction_from_block(const transaction& tx, const crypto::hash& tx_id, const crypto::hash& bl_id, uint64_t bl_height);
bool 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);
bool push_transaction_to_global_outs_index(const transaction& tx, const crypto::hash& tx_id, std::vector<uint64_t>& global_indexes);
bool pop_transaction_from_global_index(const transaction& tx, const crypto::hash& tx_id);
bool get_last_n_blocks_sizes(std::vector<size_t>& sz, size_t count) const;

View file

@ -138,21 +138,34 @@ bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints, bool testne
size_t cur_index = first_index;
do
{
std::string url;
if (testnet)
{
records = tools::DNSResolver::instance().get_txt_record(testnet_dns_urls[cur_index], avail, valid);
url = testnet_dns_urls[cur_index];
}
else
{
records = tools::DNSResolver::instance().get_txt_record(dns_urls[cur_index], avail, valid);
url = dns_urls[cur_index];
}
if (records.size() == 0 || (avail && !valid))
records = tools::DNSResolver::instance().get_txt_record(url, avail, valid);
if (!avail)
{
LOG_PRINT_L2("DNSSEC not available for checkpoint update at URL: " << url << ", skipping.");
}
if (!valid)
{
LOG_PRINT_L2("DNSSEC validation failed for checkpoint update at URL: " << url << ", skipping.");
}
if (records.size() == 0 || !avail || !valid)
{
cur_index++;
if (cur_index == dns_urls.size())
{
cur_index = 0;
}
records.clear();
continue;
}
break;
@ -160,13 +173,7 @@ bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints, bool testne
if (records.size() == 0)
{
LOG_PRINT_L1("Fetching MoneroPulse checkpoints failed, no TXT records available.");
return true;
}
if (avail && !valid)
{
LOG_PRINT_L0("WARNING: MoneroPulse failed DNSSEC validation and/or returned no records");
LOG_PRINT_L0("WARNING: All MoneroPulse checkpoint URLs failed DNSSEC validation and/or returned no records");
return true;
}