core: fix failure to sync when a tx is already in the pool

This commit is contained in:
moneromooo-monero 2017-09-29 21:34:10 +01:00
parent fda88c8d28
commit b4c5180f2d
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
3 changed files with 28 additions and 9 deletions

View File

@ -2242,6 +2242,24 @@ bool Blockchain::get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<u
return true; return true;
} }
//------------------------------------------------------------------ //------------------------------------------------------------------
void Blockchain::on_new_tx_from_block(const cryptonote::transaction &tx)
{
#if defined(PER_BLOCK_CHECKPOINT)
// check if we're doing per-block checkpointing
if (m_db->height() < m_blocks_hash_check.size())
{
TIME_MEASURE_START(a);
m_blocks_txs_check.push_back(get_transaction_hash(tx));
TIME_MEASURE_FINISH(a);
if(m_show_time_stats)
{
size_t ring_size = tx.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(tx.vin[0]).key_offsets.size() : 0;
MINFO("HASH: " << "-" << " I/M/O: " << tx.vin.size() << "/" << ring_size << "/" << tx.vout.size() << " H: " << 0 << " chcktx: " << a);
}
}
#endif
}
//------------------------------------------------------------------
//FIXME: it seems this function is meant to be merely a wrapper around //FIXME: it seems this function is meant to be merely a wrapper around
// another function of the same name, this one adding one bit of // another function of the same name, this one adding one bit of
// functionality. Should probably move anything more than that // functionality. Should probably move anything more than that
@ -2257,19 +2275,10 @@ bool Blockchain::check_tx_inputs(transaction& tx, uint64_t& max_used_block_heigh
#if defined(PER_BLOCK_CHECKPOINT) #if defined(PER_BLOCK_CHECKPOINT)
// check if we're doing per-block checkpointing // check if we're doing per-block checkpointing
// FIXME: investigate why this block returns
if (m_db->height() < m_blocks_hash_check.size() && kept_by_block) if (m_db->height() < m_blocks_hash_check.size() && kept_by_block)
{ {
TIME_MEASURE_START(a);
m_blocks_txs_check.push_back(get_transaction_hash(tx));
max_used_block_id = null_hash; max_used_block_id = null_hash;
max_used_block_height = 0; max_used_block_height = 0;
TIME_MEASURE_FINISH(a);
if(m_show_time_stats)
{
size_t ring_size = tx.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(tx.vin[0]).key_offsets.size() : 0;
MINFO("HASH: " << "-" << " I/M/O: " << tx.vin.size() << "/" << ring_size << "/" << tx.vout.size() << " H: " << 0 << " chcktx: " << a);
}
return true; return true;
} }
#endif #endif

View File

@ -898,6 +898,13 @@ namespace cryptonote
void cancel(); void cancel();
/**
* @brief called when we see a tx originating from a block
*
* Used for handling txes from historical blocks in a fast way
*/
void on_new_tx_from_block(const cryptonote::transaction &tx);
private: private:
// TODO: evaluate whether or not each of these typedefs are left over from blockchain_storage // TODO: evaluate whether or not each of these typedefs are left over from blockchain_storage

View File

@ -880,6 +880,9 @@ namespace cryptonote
//----------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------
bool core::add_new_tx(transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) bool core::add_new_tx(transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
{ {
if (keeped_by_block)
get_blockchain_storage().on_new_tx_from_block(tx);
if(m_mempool.have_tx(tx_hash)) if(m_mempool.have_tx(tx_hash))
{ {
LOG_PRINT_L2("tx " << tx_hash << "already have transaction in tx_pool"); LOG_PRINT_L2("tx " << tx_hash << "already have transaction in tx_pool");