aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/tx_pool.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-05-14 14:06:55 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-05-25 22:23:37 +0100
commitb52abd1370cc21484d64f45504adbab47240debf (patch)
tree42c9327b4b928d008fcc61e4b7ca09c85ec9ccd9 /src/cryptonote_core/tx_pool.h
parentMerge pull request #1956 (diff)
downloadmonero-b52abd1370cc21484d64f45504adbab47240debf.tar.xz
Move txpool to the database
Integration could go further (ie, return_tx_to_pool calls should not be needed anymore, possibly other things). poolstate.bin is now obsolete.
Diffstat (limited to 'src/cryptonote_core/tx_pool.h')
-rw-r--r--src/cryptonote_core/tx_pool.h52
1 files changed, 17 insertions, 35 deletions
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index d19f83b2e..89526d82f 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -43,6 +43,7 @@
#include "math_helper.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/verification_context.h"
+#include "blockchain_db/blockchain_db.h"
#include "crypto/hash.h"
#include "rpc/core_rpc_server_commands_defs.h"
@@ -100,12 +101,12 @@ namespace cryptonote
/**
- * @copydoc add_tx(const transaction&, tx_verification_context&, bool, bool, uint8_t)
+ * @copydoc add_tx(transaction&, tx_verification_context&, bool, bool, uint8_t)
*
* @param id the transaction's hash
* @param blob_size the transaction's size
*/
- bool add_tx(const transaction &tx, const crypto::hash &id, size_t blob_size, tx_verification_context& tvc, bool kept_by_block, bool relayed, bool do_not_relay, uint8_t version);
+ bool add_tx(transaction &tx, const crypto::hash &id, size_t blob_size, tx_verification_context& tvc, bool kept_by_block, bool relayed, bool do_not_relay, uint8_t version);
/**
* @brief add a transaction to the transaction pool
@@ -124,7 +125,7 @@ namespace cryptonote
*
* @return true if the transaction passes validations, otherwise false
*/
- bool add_tx(const transaction &tx, tx_verification_context& tvc, bool kept_by_block, bool relayed, bool do_not_relay, uint8_t version);
+ bool add_tx(transaction &tx, tx_verification_context& tvc, bool kept_by_block, bool relayed, bool do_not_relay, uint8_t version);
/**
* @brief takes a transaction with the given hash from the pool
@@ -199,7 +200,7 @@ namespace cryptonote
*
* @return true
*/
- bool init(const std::string& config_folder);
+ bool init();
/**
* @brief attempts to save the transaction pool state to disk
@@ -256,11 +257,11 @@ namespace cryptonote
* @brief get a specific transaction from the pool
*
* @param h the hash of the transaction to get
- * @param tx return-by-reference the transaction requested
+ * @param tx return-by-reference the transaction blob requested
*
* @return true if the transaction is found, otherwise false
*/
- bool get_transaction(const crypto::hash& h, transaction& tx) const;
+ bool get_transaction(const crypto::hash& h, cryptonote::blobdata& txblob) const;
/**
* @brief get a list of all relayable transactions and their hashes
@@ -274,14 +275,14 @@ namespace cryptonote
*
* @return true
*/
- bool get_relayable_transactions(std::list<std::pair<crypto::hash, cryptonote::transaction>>& txs) const;
+ bool get_relayable_transactions(std::list<std::pair<crypto::hash, cryptonote::blobdata>>& txs) const;
/**
* @brief tell the pool that certain transactions were just relayed
*
* @param txs the list of transactions (and their hashes)
*/
- void set_relayed(const std::list<std::pair<crypto::hash, cryptonote::transaction>>& txs);
+ void set_relayed(const std::list<std::pair<crypto::hash, cryptonote::blobdata>>& txs);
/**
* @brief get the total number of transactions in the pool
@@ -317,28 +318,6 @@ namespace cryptonote
#define CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER 12
/**
- * @brief serialize the transaction pool to/from disk
- *
- * If the archive version passed is older than the version compiled
- * in, this function does nothing, as it cannot deserialize after a
- * format change.
- *
- * @tparam archive_t the archive class
- * @param a the archive to serialize to/from
- * @param version the archive version
- */
- template<class archive_t>
- void serialize(archive_t & a, const unsigned int version)
- {
- if(version < CURRENT_MEMPOOL_ARCHIVE_VER )
- return;
- CRITICAL_REGION_LOCAL(m_transactions_lock);
- a & m_transactions;
- a & m_spent_key_images;
- a & m_timed_out_transactions;
- }
-
- /**
* @brief information about a single transaction
*/
struct tx_details
@@ -379,6 +358,13 @@ namespace cryptonote
private:
/**
+ * @brief insert key images into m_spent_key_images
+ *
+ * @return true on success, false on error
+ */
+ bool insert_key_images(const transaction &tx, bool kept_by_block);
+
+ /**
* @brief remove old transactions from the pool
*
* After a certain time, it is assumed that a transaction which has not
@@ -452,10 +438,7 @@ namespace cryptonote
*
* @return true if the transaction is good to go, otherwise false
*/
- bool is_transaction_ready_to_go(tx_details& txd) const;
-
- //! map transactions (and related info) by their hashes
- typedef std::unordered_map<crypto::hash, tx_details > transactions_container;
+ bool is_transaction_ready_to_go(txpool_tx_meta_t& txd, transaction &tx) const;
//TODO: confirm the below comments and investigate whether or not this
// is the desired behavior
@@ -472,7 +455,6 @@ namespace cryptonote
public:
#endif
mutable epee::critical_section m_transactions_lock; //!< lock for the pool
- transactions_container m_transactions; //!< container for transactions in the pool
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
private:
#endif