32 #include "include_base_utils.h"
37 #include <unordered_map>
38 #include <unordered_set>
40 #include <boost/serialization/version.hpp>
41 #include <boost/utility.hpp>
44 #include "string_tools.h"
46 #include "math_helper.h"
71 if (
a.first.first >
b.first.first)
return true;
72 else if (
a.first.first <
b.first.first)
return false;
73 else if (
a.first.second <
b.first.second)
return true;
74 else if (
a.first.second >
b.first.second)
return false;
75 else if (
a.second !=
b.second)
return true;
213 bool init(
size_t max_txpool_weight = 0,
bool mine_stem_txes =
false);
239 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);
248 void get_transactions(std::vector<transaction>& txs,
bool include_sensitive =
false)
const;
311 bool check_for_key_images(
const std::vector<crypto::key_image>& key_images, std::vector<bool>& spent)
const;
364 std::string
print_pool(
bool short_format)
const;
400 #define CURRENT_MEMPOOL_ARCHIVE_VER 11
401 #define CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER 13
452 bool get_complement(
const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes)
const;
555 void prune(
size_t bytes = 0);
568 #if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
572 #if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
613 mutable std::unordered_map<crypto::hash, std::tuple<bool, tx_verification_context, uint64_t, crypto::hash>>
m_input_cache;
626 template<
class archive_t>
Definition: blockchain.h:96
Definition: cryptonote_basic.h:160
Definition: cryptonote_basic.h:194
bool operator()(const tx_by_fee_and_receive_time_entry &a, const tx_by_fee_and_receive_time_entry &b) const
Definition: tx_pool.h:68
Transaction pool, handles transactions which are not part of a block.
Definition: tx_pool.h:98
void unlock() const
unlocks the transaction pool
Definition: tx_pool.cpp:1203
sorted_tx_container::iterator find_tx_in_sorted_container(const crypto::hash &id) const
get an iterator to a transaction in the sorted container
Definition: tx_pool.cpp:673
bool insert_key_images(const transaction_prefix &tx, const crypto::hash &txid, relay_method tx_relay)
insert key images into m_spent_key_images
Definition: tx_pool.cpp:465
void lock() const
locks the transaction pool
Definition: tx_pool.cpp:1198
bool have_tx(const crypto::hash &id, relay_category tx_category) const
checks if the pool has a transaction with the given hash
Definition: tx_pool.cpp:1163
void on_idle()
action to take periodically
Definition: tx_pool.cpp:668
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 &pruned)
takes a transaction with the given hash from the pool
Definition: tx_pool.cpp:526
epee::math_helper::once_a_time_seconds< 30 > m_remove_stuck_tx_interval
interval on which to check for stale/"stuck" transactions
Definition: tx_pool.h:581
void get_transactions(std::vector< transaction > &txs, bool include_sensitive=false) const
get a list of all transactions in the pool
Definition: tx_pool.cpp:872
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
Definition: tx_pool.cpp:1063
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
Definition: tx_pool.cpp:1155
bool get_transaction(const crypto::hash &h, cryptonote::blobdata &txblob, relay_category tx_category) const
get a specific transaction from the pool
Definition: tx_pool.cpp:1133
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.
Definition: tx_pool.cpp:1393
bool remove_transaction_keyimages(const transaction_prefix &tx, const crypto::hash &txid)
forget a transaction's spent key images
Definition: tx_pool.cpp:496
std::atomic< time_t > m_next_check
Next timestamp that a DB check for relayable txes is allowed.
Definition: tx_pool.h:618
size_t m_txpool_max_weight
Definition: tx_pool.h:609
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
Definition: tx_pool.cpp:1147
bool get_relayable_transactions(std::vector< std::tuple< crypto::hash, cryptonote::blobdata, relay_method >> &txs)
get a list of all relayable transactions and their hashes
Definition: tx_pool.cpp:746
key_images_container m_spent_key_images
container for spent key images from the transactions in the pool
Definition: tx_pool.h:577
std::unordered_set< crypto::hash > m_timed_out_transactions
transactions which are unlikely to be included in blocks
Definition: tx_pool.h:605
bool check_tx_inputs(const std::function< cryptonote::transaction &(void)> &get_tx, const crypto::hash &txid, uint64_t &max_used_block_height, crypto::hash &max_used_block_id, tx_verification_context &tvc, bool kept_by_block=false) const
cache/call Blockchain::check_tx_inputs results
Definition: tx_pool.cpp:1208
uint64_t cookie() const
return the cookie
Definition: tx_pool.h:384
bool get_complement(const std::vector< crypto::hash > &hashes, std::vector< cryptonote::blobdata > &txes) const
get transactions not in the passed set
Definition: tx_pool.cpp:635
bool add_tx(transaction &tx, const crypto::hash &id, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context &tvc, relay_method tx_relay, bool relayed, uint8_t version)
Definition: tx_pool.cpp:138
void set_txpool_max_weight(size_t bytes)
set the max cumulative txpool weight in bytes
Definition: tx_pool.cpp:400
bool have_tx_keyimges_as_spent(const transaction &tx, const crypto::hash &txid) const
check if any spent key image in a transaction is in the pool
Definition: tx_pool.cpp:1170
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=false) const
get information about all transactions and key images in the pool
Definition: tx_pool.cpp:1004
static bool append_key_images(std::unordered_set< crypto::key_image > &kic, const transaction_prefix &tx)
append the key images from a transaction to the given set
Definition: tx_pool.cpp:1305
static bool have_key_images(const std::unordered_set< crypto::key_image > &kic, const transaction_prefix &tx)
check if any of a transaction's spent key images are present in a given set
Definition: tx_pool.cpp:1294
std::string print_pool(bool short_format) const
get a string containing human-readable pool information
Definition: tx_pool.cpp:1360
epee::critical_section m_transactions_lock
lock for the pool
Definition: tx_pool.h:571
sorted_tx_container m_txs_by_fee_and_receive_time
< container for transactions organized by fee per size and receive time
Definition: tx_pool.h:585
void set_relayed(epee::span< const crypto::hash > hashes, relay_method tx_relay)
tell the pool that certain transactions were just relayed
Definition: tx_pool.cpp:824
Blockchain & m_blockchain
reference to the Blockchain object
Definition: tx_pool.h:607
tx_memory_pool(Blockchain &bchs)
Constructor.
Definition: tx_pool.cpp:131
size_t validate(uint8_t version)
remove transactions from the pool which are no longer valid
Definition: tx_pool.cpp:1538
bool m_mine_stem_txes
Definition: tx_pool.h:611
bool init(size_t max_txpool_weight=0, bool mine_stem_txes=false)
loads pool state (if any) from disk, and initializes pool
Definition: tx_pool.cpp:1602
std::unordered_map< crypto::key_image, std::unordered_set< crypto::hash > > key_images_container
map key images to transactions which spent them
Definition: tx_pool.h:566
bool remove_stuck_transactions()
remove old transactions from the pool
Definition: tx_pool.cpp:683
bool get_transaction_info(const crypto::hash &txid, tx_details &td) const
get infornation about a single transaction
Definition: tx_pool.cpp:582
void get_transaction_hashes(std::vector< crypto::hash > &txs, bool include_sensitive=false) const
get a list of all transaction hashes in the pool
Definition: tx_pool.cpp:892
void mark_double_spend(const transaction &tx)
mark all transactions double spending the one passed
Definition: tx_pool.cpp:1316
size_t get_txpool_weight() const
get the cumulative txpool weight in bytes
Definition: tx_pool.cpp:394
bool have_tx_keyimg_as_spent(const crypto::key_image &key_im, const crypto::hash &txid) const
check if a transaction in the pool has a given spent key image
Definition: tx_pool.cpp:1183
std::unordered_map< crypto::hash, std::tuple< bool, tx_verification_context, uint64_t, crypto::hash > > m_input_cache
Definition: tx_pool.h:613
void get_transaction_backlog(std::vector< tx_backlog_entry > &backlog, bool include_sensitive=false) const
get (weight, fee, receive time) for all transaction in the pool
Definition: tx_pool.cpp:904
std::atomic< uint64_t > m_cookie
incremented at each change
Definition: tx_pool.h:587
void get_transaction_stats(struct txpool_stats &stats, bool include_sensitive=false) const
get a summary statistics of all transaction hashes in the pool
Definition: tx_pool.cpp:917
std::unordered_map< crypto::hash, transaction > m_parsed_tx_cache
Definition: tx_pool.h:615
void prune(size_t bytes=0)
prune lowest fee/byte txes till we're not above bytes
Definition: tx_pool.cpp:406
size_t m_txpool_weight
Definition: tx_pool.h:610
bool is_transaction_ready_to_go(txpool_tx_meta_t &txd, const crypto::hash &txid, const cryptonote::blobdata &txblob, transaction &tx) const
check if a transaction is a valid candidate for inclusion in a block
Definition: tx_pool.cpp:1227
size_t get_transactions_count(bool include_sensitive=false) const
get the total number of transactions in the pool
Definition: tx_pool.cpp:865
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
Definition: tx_pool.cpp:1111
bool deinit()
attempts to save the transaction pool state to disk
Definition: tx_pool.cpp:1666
string a
Definition: MakeCryptoOps.py:15
int b
Definition: base.py:1
void serialize(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
Definition: unordered_containers_boost_serialization.h:126
Definition: unordered_containers_boost_serialization.h:38
POD_CLASS key_image
Definition: crypto.h:87
POD_CLASS hash
Definition: hash.h:48
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition: message_data_structs.h:107
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
std::set< tx_by_fee_and_receive_time_entry, txCompare > sorted_tx_container
container for sorting transactions by fee per unit size
Definition: tx_pool.h:81
relay_category
Definition: blockchain_db.h:110
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:37
std::string blobdata
Definition: blobdatatype.h:39
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
Definition: tx_pool.h:57
version
Supported socks variants.
Definition: socks.h:58
Definition: binary_utils.h:36
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER)
Definition: cryptonote_basic.h:464
information about a single transaction
Definition: tx_pool.h:407
transaction tx
the transaction
Definition: tx_pool.h:408
bool do_not_relay
to avoid relay this transaction to the network
Definition: tx_pool.h:439
uint64_t max_used_block_height
the height of the highest block referenced by an input
Definition: tx_pool.h:413
crypto::hash last_failed_id
the hash of the highest block the transaction referenced when last checking it failed
Definition: tx_pool.h:433
uint64_t fee
the transaction's fee amount
Definition: tx_pool.h:411
bool kept_by_block
whether or not the transaction has been in a block before
Definition: tx_pool.h:419
size_t weight
the transaction's weight
Definition: tx_pool.h:410
time_t last_relayed_time
the last time the transaction was relayed to the network
Definition: tx_pool.h:437
bool relayed
whether or not the transaction has been relayed to the network
Definition: tx_pool.h:438
crypto::hash max_used_block_id
the hash of the highest block referenced by an input
Definition: tx_pool.h:412
size_t blob_size
the transaction's size
Definition: tx_pool.h:409
uint64_t last_failed_height
the highest block the transaction referenced when last checking it failed
Definition: tx_pool.h:426
bool double_spend_seen
true iff another tx was seen double spending this one
Definition: tx_pool.h:441
time_t receive_time
the time when the transaction entered the pool
Definition: tx_pool.h:435
Definition: verification_context.h:41
Definition: core_rpc_server_commands_defs.h:1502
#define CURRENT_MEMPOOL_ARCHIVE_VER
Definition: tx_pool.h:400
#define CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER
Definition: tx_pool.h:401