36 #include <unordered_map> 37 #include <unordered_set> 39 #include <boost/serialization/version.hpp> 40 #include <boost/utility.hpp> 68 if (
a.first.first > b.first.first)
return true;
69 else if (
a.first.first < b.first.first)
return false;
70 else if (
a.first.second < b.first.second)
return true;
71 else if (
a.first.second > b.first.second)
return false;
72 else if (
a.second != b.second)
return true;
208 bool init(
size_t max_txpool_weight = 0);
243 void get_transactions(std::vector<transaction>& txs,
bool include_unrelayed_txes =
true)
const;
261 void get_transaction_backlog(std::vector<tx_backlog_entry>& backlog,
bool include_unrelayed_txes =
true)
const;
313 bool check_for_key_images(
const std::vector<crypto::key_image>& key_images, std::vector<bool> spent)
const;
345 void set_relayed(
const std::vector<std::pair<crypto::hash, cryptonote::blobdata>>& txs);
397 #define CURRENT_MEMPOOL_ARCHIVE_VER 11 398 #define CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER 13 462 bool remove_stuck_transactions();
488 bool key_images_already_spent(
const transaction &tx)
const;
498 bool utxo_nonexistent(
const transaction &tx)
const;
525 static bool have_key_images(
const std::unordered_set<crypto::key_image>& kic,
const transaction_prefix& tx);
527 static bool have_utxos(
const std::unordered_set<std::string>& utxos,
const transaction_prefix& tx);
537 static bool append_key_images(std::unordered_set<crypto::key_image>& kic,
const transaction_prefix& tx);
539 static bool append_utxos(std::unordered_set<std::string>& utxos,
const transaction_prefix& tx);
556 void mark_double_spend_or_nonexistent_utxo(
const transaction &tx);
563 void prune(
size_t bytes = 0);
574 typedef std::unordered_map<crypto::key_image, std::unordered_set<crypto::hash> > key_images_container;
576 typedef std::unordered_map<std::string, std::unordered_set<crypto::hash> > utxos_container;
578 #if defined(DEBUG_CREATE_BLOCK_TEMPLATE) 582 #if defined(DEBUG_CREATE_BLOCK_TEMPLATE) 587 key_images_container m_spent_key_images;
590 utxos_container m_spent_utxos;
600 std::atomic<uint64_t> m_cookie;
609 sorted_tx_container::iterator find_tx_in_sorted_container(
const crypto::hash&
id)
const;
618 std::unordered_set<crypto::hash> m_timed_out_transactions;
622 size_t m_txpool_max_weight;
623 size_t m_txpool_weight;
625 mutable std::unordered_map<crypto::hash, std::tuple<bool, tx_verification_context, uint64_t, crypto::hash>> m_input_cache;
627 std::unordered_map<crypto::hash, transaction> m_parsed_tx_cache;
635 template<
class archive_t>
void on_idle()
action to take periodically
#define CURRENT_MEMPOOL_ARCHIVE_VER
bool relayed
whether or not the transaction has been relayed to the network
uint64_t cookie() const
return the cookie
crypto::hash max_used_block_id
the hash of the highest block referenced by an input
crypto::hash last_failed_id
the hash of the highest block the transaction referenced when last checking it failed ...
uint64_t max_used_block_height
the height of the highest block referenced by an input
bool add_tx(transaction &tx, const crypto::hash &id, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context &tvc, bool kept_by_block, bool relayed, bool do_not_relay, uint8_t version)
void serialize(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
void get_transactions(std::vector< transaction > &txs, bool include_unrelayed_txes=true) const
get a list of all transactions in the pool
size_t get_txpool_weight() const
get the cumulative txpool weight in bytes
void get_transaction_hashes(std::vector< crypto::hash > &txs, bool include_unrelayed_txes=true) const
get a list of all transaction hashes in the pool
transaction tx
the transaction
bool do_not_relay
to avoid relay this transaction to the network
size_t get_transactions_count(bool include_unrelayed_txes=true) const
get the total number of transactions in the pool
time_t receive_time
the time when the transaction entered the pool
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
bool take_tx(const crypto::hash &id, transaction &tx, cryptonote::blobdata &txblob, size_t &tx_weight, uint64_t &fee, bool &relayed, bool &do_not_relay, bool &double_spend_seen, bool &nonexistent_utxo_seen)
takes a transaction with the given hash from the pool
#define CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER
bool init(size_t max_txpool_weight=0)
loads pool state (if any) from disk, and initializes pool
Holds cryptonote related classes and helpers.
bool on_blockchain_inc(uint64_t new_block_height, const crypto::hash &top_block_id)
action to take when notified of a block added to the blockchain
size_t validate(uint8_t version)
remove transactions from the pool which are no longer valid
bool operator()(const tx_by_fee_and_receive_time_entry &a, const tx_by_fee_and_receive_time_entry &b) const
bool nonexistent_utxo_seen
std::pair< std::pair< double, std::time_t >, crypto::hash > tx_by_fee_and_receive_time_entry
pair of <transaction fee, transaction hash> for organization
size_t blob_size
the transaction's size
unsigned __int64 uint64_t
uint64_t last_failed_height
the highest block the transaction referenced when last checking it failed
BOOST_CLASS_VERSION(nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< tests::proxy_core > >, 1)
void set_relayed(const std::vector< std::pair< crypto::hash, cryptonote::blobdata >> &txs)
tell the pool that certain transactions were just relayed
bool get_transactions_and_spent_keys_info(std::vector< tx_info > &tx_infos, std::vector< spent_key_image_info > &key_image_infos, bool include_sensitive_data=true) const
get information about all transactions and key images in the pool
uint64_t fee
the transaction's fee amount
void get_transaction_backlog(std::vector< tx_backlog_entry > &backlog, bool include_unrelayed_txes=true) const
get (weight, fee, receive time) for all transaction in the pool
version
Supported socks variants.
tx_memory_pool(Blockchain &bchs)
Constructor.
size_t weight
the transaction's weight
bool check_for_key_images(const std::vector< crypto::key_image > &key_images, std::vector< bool > spent) const
check for presence of key images in the pool
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Transaction pool, handles transactions which are not part of a block.
void unlock() const
unlocks the transaction pool
bool deinit()
attempts to save the transaction pool state to disk
bool get_transaction(const crypto::hash &h, cryptonote::blobdata &txblob) const
get a specific transaction from the pool
information about a single transaction
std::set< tx_by_fee_and_receive_time_entry, txCompare > sorted_tx_container
container for sorting transactions by fee per unit size
void set_txpool_max_weight(size_t bytes)
set the max cumulative txpool weight in bytes
bool kept_by_block
whether or not the transaction has been in a block before
bool have_tx(const crypto::hash &id) const
checks if the pool has a transaction with the given hash
bool fill_block_template(block &bl, size_t median_weight, uint64_t already_generated_coins, size_t &total_weight, uint64_t &fee, uint64_t &expected_reward, uint8_t version)
Chooses transactions for a block to include.
bool utxo_spent_in_pool(const txin_to_key_public &in) const
get a summary statistics of all transaction hashes in the pool
bool on_blockchain_dec(uint64_t new_block_height, const crypto::hash &top_block_id)
action to take when notified of a block removed from the blockchain
time_t last_relayed_time
the last time the transaction was relayed to the network
void lock() const
locks the transaction pool
bool double_spend_seen
true iff another tx was seen double spending this one
void get_transaction_stats(struct txpool_stats &stats, bool include_unrelayed_txes=true) const
get a summary statistics of all transaction hashes in the pool
bool get_pool_for_rpc(std::vector< cryptonote::rpc::tx_in_pool > &tx_infos, cryptonote::rpc::key_images_with_tx_hashes &key_image_infos) const
get information about all transactions and key images in the pool
std::string print_pool(bool short_format) const
get a string containing human-readable pool information
bool get_relayable_transactions(std::vector< std::pair< crypto::hash, cryptonote::blobdata >> &txs) const
get a list of all relayable transactions and their hashes