aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/blockchain_db.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/blockchain_db/blockchain_db.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/blockchain_db/blockchain_db.h')
-rw-r--r--src/blockchain_db/blockchain_db.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index f5710550b..9dd343f4b 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -124,6 +124,27 @@ struct tx_data_t
};
#pragma pack(pop)
+/**
+ * @brief a struct containing txpool per transaction metadata
+ */
+struct txpool_tx_meta_t
+{
+ crypto::hash max_used_block_id;
+ crypto::hash last_failed_id;
+ uint64_t blob_size;
+ uint64_t fee;
+ uint64_t max_used_block_height;
+ uint64_t last_failed_height;
+ uint64_t receive_time;
+ uint64_t last_relayed_time;
+ // 112 bytes
+ uint8_t kept_by_block;
+ uint8_t relayed;
+ uint8_t do_not_relay;
+
+ uint8_t padding[77]; // till 192 bytes
+};
+
/***********************************
* Exception Definitions
***********************************/
@@ -1252,6 +1273,71 @@ public:
virtual bool has_key_image(const crypto::key_image& img) const = 0;
/**
+ * @brief add a txpool transaction
+ *
+ * @param details the details of the transaction to add
+ */
+ virtual void add_txpool_tx(const transaction &tx, const txpool_tx_meta_t& details) = 0;
+
+ /**
+ * @brief update a txpool transaction's metadata
+ *
+ * @param txid the txid of the transaction to update
+ * @param details the details of the transaction to update
+ */
+ virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& details) = 0;
+
+ /**
+ * @brief get the number of transactions in the txpool
+ */
+ virtual uint64_t get_txpool_tx_count() const = 0;
+
+ /**
+ * @brief check whether a txid is in the txpool
+ */
+ virtual bool txpool_has_tx(const crypto::hash &txid) const = 0;
+
+ /**
+ * @brief remove a txpool transaction
+ *
+ * @param txid the transaction id of the transation to remove
+ */
+ virtual void remove_txpool_tx(const crypto::hash& txid) = 0;
+
+ /**
+ * @brief get a txpool transaction's metadata
+ *
+ * @param txid the transaction id of the transation to lookup
+ *
+ * @return the metadata associated with that transaction
+ */
+ virtual txpool_tx_meta_t get_txpool_tx_meta(const crypto::hash& txid) const = 0;
+
+ /**
+ * @brief get a txpool transaction's blob
+ *
+ * @param txid the transaction id of the transation to lookup
+ *
+ * @return the blob for that transaction
+ */
+ virtual cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid) const = 0;
+
+ /**
+ * @brief runs a function over all txpool transactions
+ *
+ * The subclass should run the passed function for each txpool tx it has
+ * stored, passing the tx id and metadata as its parameters.
+ *
+ * If any call to the function returns false, the subclass should return
+ * false. Otherwise, the subclass returns true.
+ *
+ * @param std::function fn the function to run
+ *
+ * @return false if the function returns false for any transaction, otherwise true
+ */
+ virtual bool for_all_txpool_txes(std::function<bool(const crypto::hash&, const txpool_tx_meta_t&, const cryptonote::blobdata*)>, bool include_blob = false) const = 0;
+
+ /**
* @brief runs a function over all key images stored
*
* The subclass should run the passed function for each key image it has