|
Electroneum
|
Transaction pool, handles transactions which are not part of a block. More...
#include <tx_pool.h>


Classes | |
| struct | tx_details |
| information about a single transaction More... | |
Public Member Functions | |
| tx_memory_pool (Blockchain &bchs) | |
| Constructor. More... | |
| 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) |
| bool | add_tx (transaction &tx, tx_verification_context &tvc, bool kept_by_block, bool relayed, bool do_not_relay, uint8_t version) |
| add a transaction to the transaction pool More... | |
| 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 More... | |
| bool | have_tx (const crypto::hash &id) const |
| checks if the pool has a transaction with the given hash More... | |
| 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 More... | |
| 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 More... | |
| void | on_idle () |
| action to take periodically More... | |
| void | lock () const |
| locks the transaction pool More... | |
| void | unlock () const |
| unlocks the transaction pool More... | |
| bool | init (size_t max_txpool_weight=0) |
| loads pool state (if any) from disk, and initializes pool More... | |
| bool | deinit () |
| attempts to save the transaction pool state to disk More... | |
| 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. More... | |
| void | get_transactions (std::vector< transaction > &txs, bool include_unrelayed_txes=true) const |
| get a list of all transactions in the pool More... | |
| 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 More... | |
| 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 More... | |
| 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 More... | |
| bool | utxo_spent_in_pool (const txin_to_key_public &in) const |
| get a summary statistics of all transaction hashes in the pool More... | |
| 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 More... | |
| 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 More... | |
| 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 More... | |
| bool | get_transaction (const crypto::hash &h, cryptonote::blobdata &txblob) const |
| get a specific transaction from the pool More... | |
| bool | get_relayable_transactions (std::vector< std::pair< crypto::hash, cryptonote::blobdata >> &txs) const |
| get a list of all relayable transactions and their hashes More... | |
| void | set_relayed (const std::vector< std::pair< crypto::hash, cryptonote::blobdata >> &txs) |
| tell the pool that certain transactions were just relayed More... | |
| size_t | get_transactions_count (bool include_unrelayed_txes=true) const |
| get the total number of transactions in the pool More... | |
| std::string | print_pool (bool short_format) const |
| get a string containing human-readable pool information More... | |
| size_t | validate (uint8_t version) |
| remove transactions from the pool which are no longer valid More... | |
| uint64_t | cookie () const |
| return the cookie More... | |
| size_t | get_txpool_weight () const |
| get the cumulative txpool weight in bytes More... | |
| void | set_txpool_max_weight (size_t bytes) |
| set the max cumulative txpool weight in bytes More... | |
Transaction pool, handles transactions which are not part of a block.
This class handles all transactions which have been received, but not as part of a block.
This handling includes: storing the transactions organizing the transactions by fee per weight unit taking/giving transactions to and from various other components saving the transactions to disk on shutdown helping create a new block template by choosing transactions for it
| cryptonote::tx_memory_pool::tx_memory_pool | ( | Blockchain & | bchs | ) |
Constructor.
| bchs | a Blockchain class instance, for getting chain info |
Definition at line 117 of file tx_pool.cpp.
| bool cryptonote::tx_memory_pool::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 | ||
| ) |
| id | the transaction's hash |
| tx_weight | the transaction's weight |
Definition at line 122 of file tx_pool.cpp.

| bool cryptonote::tx_memory_pool::add_tx | ( | transaction & | tx, |
| tx_verification_context & | tvc, | ||
| bool | kept_by_block, | ||
| bool | relayed, | ||
| bool | do_not_relay, | ||
| uint8_t | version | ||
| ) |
add a transaction to the transaction pool
Most likely the transaction will come from the network, but it is also possible for transactions to come from popped blocks during a reorg, or from local clients creating a transaction and submitting it to the network
| tx | the transaction to be added |
| tvc | return-by-reference status about the transaction verification |
| kept_by_block | has this transaction been in a block? |
| relayed | was this transaction from the network or a local client? |
| do_not_relay | to avoid relaying the transaction to the network |
| version | the version used to create the transaction |
Definition at line 524 of file tx_pool.cpp.
| bool cryptonote::tx_memory_pool::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
| key_images | [in] vector of key images to check |
| spent | [out] vector of bool to return |
Definition at line 1151 of file tx_pool.cpp.

|
inline |
| bool cryptonote::tx_memory_pool::deinit | ( | ) |
attempts to save the transaction pool state to disk
Currently fails (returns false) if the data directory from init() does not exist and cannot be created, but returns true even if saving to disk is unsuccessful.
Definition at line 1800 of file tx_pool.cpp.

| bool cryptonote::tx_memory_pool::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.
| bl | return-by-reference the block to fill in with transactions |
| median_weight | the current median block weight |
| already_generated_coins | the current total number of coins "minted" |
| total_weight | return-by-reference the total weight of the new block |
| fee | return-by-reference the total of fees from the included transactions |
| expected_reward | return-by-reference the total reward awarded to the miner finding this block, including transaction fees |
| version | hard fork version to use for consensus rules |
Definition at line 1535 of file tx_pool.cpp.


| bool cryptonote::tx_memory_pool::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
see documentation on tx_in_pool and key_images_with_tx_hashes for more details
| tx_infos | [out] the transactions' information |
| key_image_infos | [out] the spent key images' information |
Definition at line 1102 of file tx_pool.cpp.


| bool cryptonote::tx_memory_pool::get_relayable_transactions | ( | std::vector< std::pair< crypto::hash, cryptonote::blobdata >> & | txs | ) | const |
get a list of all relayable transactions and their hashes
"relayable" in this case means: nonzero fee hasn't been relayed too recently isn't old enough that relaying it is considered harmful Note a transaction can be "relayable" even if do_not_relay is true
| txs | return-by-reference the transactions and their hashes |
Definition at line 836 of file tx_pool.cpp.

| bool cryptonote::tx_memory_pool::get_transaction | ( | const crypto::hash & | h, |
| cryptonote::blobdata & | txblob | ||
| ) | const |
get a specific transaction from the pool
| h | the hash of the transaction to get |
| tx | return-by-reference the transaction blob requested |
Definition at line 1166 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::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
| txs | return-by-reference that data |
| include_unrelayed_txes | include unrelayed txes in the result |
Definition at line 934 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::get_transaction_hashes | ( | std::vector< crypto::hash > & | txs, |
| bool | include_unrelayed_txes = true |
||
| ) | const |
get a list of all transaction hashes in the pool
| txs | return-by-reference the list of transactions |
| include_unrelayed_txes | include unrelayed txes in the result |
Definition at line 923 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::get_transaction_stats | ( | struct txpool_stats & | stats, |
| bool | include_unrelayed_txes = true |
||
| ) | const |
get a summary statistics of all transaction hashes in the pool
| stats | return-by-reference the pool statistics |
| include_unrelayed_txes | include unrelayed txes in the result |
Definition at line 946 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::get_transactions | ( | std::vector< transaction > & | txs, |
| bool | include_unrelayed_txes = true |
||
| ) | const |
get a list of all transactions in the pool
| txs | return-by-reference the list of transactions |
| include_unrelayed_txes | include unrelayed txes in the result |
Definition at line 904 of file tx_pool.cpp.


| bool cryptonote::tx_memory_pool::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
see documentation on tx_info and spent_key_image_info for more details
| tx_infos | return-by-reference the transactions' information |
| key_image_infos | return-by-reference the spent key images' information |
| include_sensitive_data | include unrelayed txes and fields that are sensitive to the node privacy |
Definition at line 1026 of file tx_pool.cpp.


| size_t cryptonote::tx_memory_pool::get_transactions_count | ( | bool | include_unrelayed_txes = true | ) | const |
get the total number of transactions in the pool
Definition at line 897 of file tx_pool.cpp.


| size_t cryptonote::tx_memory_pool::get_txpool_weight | ( | ) | const |
get the cumulative txpool weight in bytes
Definition at line 535 of file tx_pool.cpp.
| bool cryptonote::tx_memory_pool::have_tx | ( | const crypto::hash & | id | ) | const |
checks if the pool has a transaction with the given hash
| id | the hash to look for |
Definition at line 1196 of file tx_pool.cpp.


| bool cryptonote::tx_memory_pool::init | ( | size_t | max_txpool_weight = 0 | ) |
loads pool state (if any) from disk, and initializes pool
| max_txpool_weight | the max weight in bytes |
Definition at line 1731 of file tx_pool.cpp.

| void cryptonote::tx_memory_pool::lock | ( | void | ) | const |
locks the transaction pool
Definition at line 1255 of file tx_pool.cpp.


| bool cryptonote::tx_memory_pool::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
Currently does nothing
| new_block_height | the height of the blockchain after the change |
| top_block_id | the hash of the new top block |
Definition at line 1188 of file tx_pool.cpp.
| bool cryptonote::tx_memory_pool::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
Currently does nothing
| new_block_height | the height of the blockchain after the change |
| top_block_id | the hash of the new top block |
Definition at line 1180 of file tx_pool.cpp.
| void cryptonote::tx_memory_pool::on_idle | ( | ) |
action to take periodically
Currently checks transaction pool for stale ("stuck") transactions
Definition at line 758 of file tx_pool.cpp.


| std::string cryptonote::tx_memory_pool::print_pool | ( | bool | short_format | ) | const |
get a string containing human-readable pool information
| short_format | whether to use a shortened format for the info |
Definition at line 1502 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::set_relayed | ( | const std::vector< std::pair< crypto::hash, cryptonote::blobdata >> & | txs | ) |
tell the pool that certain transactions were just relayed
| txs | the list of transactions (and their hashes) |
Definition at line 870 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::set_txpool_max_weight | ( | size_t | bytes | ) |
set the max cumulative txpool weight in bytes
| bytes | the max cumulative txpool weight in bytes |
Definition at line 541 of file tx_pool.cpp.
| bool cryptonote::tx_memory_pool::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
| id | the hash of the transaction |
| tx | return-by-reference the transaction taken |
| txblob | return-by-reference the transaction as a blob |
| tx_weight | return-by-reference the transaction's weight |
| fee | the transaction fee |
| relayed | return-by-reference was transaction relayed to us by the network? |
| do_not_relay | return-by-reference is transaction not to be relayed to the network? |
| double_spend_seen | return-by-reference was a double spend seen for that transaction? |
| nonexistent_utxo_seen | return-by-reference was a nonexistent utxo seen for that transaction? |
Definition at line 702 of file tx_pool.cpp.


| void cryptonote::tx_memory_pool::unlock | ( | void | ) | const |
unlocks the transaction pool
Definition at line 1260 of file tx_pool.cpp.


| bool cryptonote::tx_memory_pool::utxo_spent_in_pool | ( | const txin_to_key_public & | in | ) | const |
get a summary statistics of all transaction hashes in the pool
| in | input to check the pool spent status of |
Definition at line 1220 of file tx_pool.cpp.

| size_t cryptonote::tx_memory_pool::validate | ( | uint8_t | version | ) |
remove transactions from the pool which are no longer valid
With new versions of the currency, what conditions render a transaction invalid may change. This function clears those which were received before a version change and no longer conform to requirements.
| version | the version the transactions must conform to |
Definition at line 1667 of file tx_pool.cpp.
