mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 17:18:52 +00:00
tx_pool: do not accept txes not in a block if they timed out before
This is intended to avoid cases where a timed out tx will be re-relayed by another peer for which it has not timed out yet, which would cause the tx to stay in the network's pool for a long time (until all peers time it out before another one tries to relay it again).
This commit is contained in:
parent
eadbdf354a
commit
94b98fb5fa
@ -84,7 +84,15 @@ namespace cryptonote
|
|||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
bool tx_memory_pool::add_tx(const transaction &tx, /*const crypto::hash& tx_prefix_hash,*/ const crypto::hash &id, size_t blob_size, tx_verification_context& tvc, bool kept_by_block, bool relayed, uint8_t version)
|
bool tx_memory_pool::add_tx(const transaction &tx, /*const crypto::hash& tx_prefix_hash,*/ const crypto::hash &id, size_t blob_size, tx_verification_context& tvc, bool kept_by_block, bool relayed, uint8_t version)
|
||||||
{
|
{
|
||||||
|
// we do not accept transactions that timed out before, unless they're
|
||||||
|
// kept_by_block
|
||||||
|
if (!kept_by_block && m_timed_out_transactions.find(id) != m_timed_out_transactions.end())
|
||||||
|
{
|
||||||
|
// not clear if we should set that, since verifivation (sic) did not fail before, since
|
||||||
|
// the tx was accepted before timing out.
|
||||||
|
tvc.m_verifivation_failed = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!check_inputs_types_supported(tx))
|
if(!check_inputs_types_supported(tx))
|
||||||
{
|
{
|
||||||
@ -315,6 +323,7 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
m_txs_by_fee.erase(sorted_it);
|
m_txs_by_fee.erase(sorted_it);
|
||||||
}
|
}
|
||||||
|
m_timed_out_transactions.insert(it->first);
|
||||||
auto pit = it++;
|
auto pit = it++;
|
||||||
m_transactions.erase(pit);
|
m_transactions.erase(pit);
|
||||||
}else
|
}else
|
||||||
|
@ -110,7 +110,7 @@ namespace cryptonote
|
|||||||
/*bool flush_pool(const std::strig& folder);
|
/*bool flush_pool(const std::strig& folder);
|
||||||
bool inflate_pool(const std::strig& folder);*/
|
bool inflate_pool(const std::strig& folder);*/
|
||||||
|
|
||||||
#define CURRENT_MEMPOOL_ARCHIVE_VER 9
|
#define CURRENT_MEMPOOL_ARCHIVE_VER 10
|
||||||
|
|
||||||
template<class archive_t>
|
template<class archive_t>
|
||||||
void serialize(archive_t & a, const unsigned int version)
|
void serialize(archive_t & a, const unsigned int version)
|
||||||
@ -120,6 +120,7 @@ namespace cryptonote
|
|||||||
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
||||||
a & m_transactions;
|
a & m_transactions;
|
||||||
a & m_spent_key_images;
|
a & m_spent_key_images;
|
||||||
|
a & m_timed_out_transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tx_details
|
struct tx_details
|
||||||
@ -162,6 +163,8 @@ namespace cryptonote
|
|||||||
|
|
||||||
sorted_tx_container::iterator find_tx_in_sorted_container(const crypto::hash& id) const;
|
sorted_tx_container::iterator find_tx_in_sorted_container(const crypto::hash& id) const;
|
||||||
|
|
||||||
|
std::unordered_set<crypto::hash> m_timed_out_transactions;
|
||||||
|
|
||||||
//transactions_container m_alternative_transactions;
|
//transactions_container m_alternative_transactions;
|
||||||
|
|
||||||
std::string m_config_folder;
|
std::string m_config_folder;
|
||||||
|
Loading…
Reference in New Issue
Block a user