mirror of
https://github.com/wownero/wownero.git
synced 2026-11-18 22:35:33 +01:00
tx_pool: fix write abort and improve locking for relayable txs
This commit is contained in:
@@ -810,7 +810,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
||||||
CRITICAL_REGION_LOCAL1(m_blockchain);
|
CRITICAL_REGION_LOCAL1(m_blockchain);
|
||||||
LockedTXN lock(m_blockchain.get_db());
|
|
||||||
txs.reserve(m_blockchain.get_txpool_tx_count());
|
txs.reserve(m_blockchain.get_txpool_tx_count());
|
||||||
m_blockchain.for_all_txpool_txes([this, now, &txs, &change_timestamps, &next_check](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata_ref *){
|
m_blockchain.for_all_txpool_txes([this, now, &txs, &change_timestamps, &next_check](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata_ref *){
|
||||||
// 0 fee transactions are never relayed
|
// 0 fee transactions are never relayed
|
||||||
@@ -859,16 +858,32 @@ namespace cryptonote
|
|||||||
return true;
|
return true;
|
||||||
}, false, relay_category::relayable);
|
}, false, relay_category::relayable);
|
||||||
|
|
||||||
for (auto& elem : change_timestamps)
|
if (!change_timestamps.empty())
|
||||||
{
|
{
|
||||||
/* These transactions are still in forward or stem state, so the field
|
LockedTXN db_lock(m_blockchain.get_db());
|
||||||
represents the next time a relay should be attempted. Will be
|
bool made_an_update = false;
|
||||||
overwritten when the state is upgraded to stem, fluff or block. This
|
for (auto& elem : change_timestamps)
|
||||||
function is only called every ~2 minutes, so this resetting should be
|
{
|
||||||
unnecessary, but is primarily a precaution against potential changes
|
/* These transactions are still in forward or stem state, so the field
|
||||||
to the callback routines. */
|
represents the next time a relay should be attempted. Will be
|
||||||
elem.second.last_relayed_time = now + get_relay_delay(elem.second.last_relayed_time, elem.second.receive_time);
|
overwritten when the state is upgraded to stem, fluff or block. This
|
||||||
m_blockchain.update_txpool_tx(elem.first, elem.second);
|
function is only called every ~2 minutes, so this resetting should be
|
||||||
|
unnecessary, but is primarily a precaution against potential changes
|
||||||
|
to the callback routines. */
|
||||||
|
elem.second.last_relayed_time = now + get_relay_delay(elem.second.last_relayed_time, elem.second.receive_time);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_blockchain.update_txpool_tx(elem.first, elem.second);
|
||||||
|
made_an_update = true;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
MDEBUG("Got an exception while updating txpool meta for relayable tx " << elem.first << ", ignoring...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (made_an_update)
|
||||||
|
db_lock.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_next_check = time_t(next_check);
|
m_next_check = time_t(next_check);
|
||||||
|
|||||||
Reference in New Issue
Block a user