aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/tx_pool.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-01-15 14:46:33 -0500
committerRiccardo Spagni <ric@spagni.net>2017-01-15 14:46:33 -0500
commit8bd2c2e551fe36ff6f9fee985d78784fb04ec146 (patch)
tree9947d03a263268f81c6485ac2be3c2a25659ce9a /src/cryptonote_core/tx_pool.h
parent935f50471ccaf70c72fec78394908a789748a0b1 (diff)
parent36ba311cf4aafe18c01284cf70bec3008060bbb4 (diff)
downloadmonzero-core-8bd2c2e551fe36ff6f9fee985d78784fb04ec146.tar.gz
monzero-core-8bd2c2e551fe36ff6f9fee985d78784fb04ec146.tar.xz
monzero-core-8bd2c2e551fe36ff6f9fee985d78784fb04ec146.zip
Merge pull request #1563
36ba311c Prioritize older transactions in the mempool (Miguel Herranz)
Diffstat (limited to 'src/cryptonote_core/tx_pool.h')
-rw-r--r--src/cryptonote_core/tx_pool.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index 32a05b0f4..9258a0c38 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -54,23 +54,25 @@ namespace cryptonote
/************************************************************************/
//! pair of <transaction fee, transaction hash> for organization
- typedef std::pair<double, crypto::hash> tx_by_fee_entry;
+ typedef std::pair<std::pair<double, std::time_t>, crypto::hash> tx_by_fee_and_receive_time_entry;
class txCompare
{
public:
- bool operator()(const tx_by_fee_entry& a, const tx_by_fee_entry& b)
+ bool operator()(const tx_by_fee_and_receive_time_entry& a, const tx_by_fee_and_receive_time_entry& b)
{
// sort by greatest first, not least
- if (a.first > b.first) return true;
- else if (a.first < b.first) return false;
+ if (a.first.first > b.first.first) return true;
+ else if (a.first.first < b.first.first) return false;
+ else if (a.first.second < b.first.second) return true;
+ else if (a.first.second > b.first.second) return false;
else if (a.second != b.second) return true;
else return false;
}
};
//! container for sorting transactions by fee per unit size
- typedef std::set<tx_by_fee_entry, txCompare> sorted_tx_container;
+ typedef std::set<tx_by_fee_and_receive_time_entry, txCompare> sorted_tx_container;
/**
* @brief Transaction pool, handles transactions which are not part of a block
@@ -473,7 +475,8 @@ private:
epee::math_helper::once_a_time_seconds<30> m_remove_stuck_tx_interval;
//TODO: look into doing this better
- sorted_tx_container m_txs_by_fee; //!< container for transactions organized by fee per size
+ //!< container for transactions organized by fee per size and receive time
+ sorted_tx_container m_txs_by_fee_and_receive_time;
/**
* @brief get an iterator to a transaction in the sorted container