Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/crypto/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ namespace crypto {

constexpr static crypto::hash null_hash = {};
constexpr static crypto::hash8 null_hash8 = {};

inline bool operator<(const hash &lhs, const hash &rhs) noexcept { return memcmp(&lhs, &rhs, sizeof(hash)) < 0; }
inline bool operator>(const hash &lhs, const hash &rhs) noexcept { return rhs < lhs; }
}

CRYPTO_MAKE_HASHABLE(hash)
Expand Down
4 changes: 2 additions & 2 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,9 +1850,9 @@ namespace cryptonote
m_blockchain_storage.flush_invalid_blocks();
}
//-----------------------------------------------------------------------------------------------
bool core::get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes)
bool core::get_txpool_complement(std::vector<crypto::hash> hashes, std::vector<cryptonote::blobdata> &txes)
{
return m_mempool.get_complement(hashes, txes);
return m_mempool.get_complement(std::move(hashes), txes);
}
//-----------------------------------------------------------------------------------------------
bool core::update_blockchain_pruning()
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/cryptonote_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ namespace cryptonote
*
* @return true iff success, false otherwise
*/
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes);
bool get_txpool_complement(std::vector<crypto::hash> hashes, std::vector<cryptonote::blobdata> &txes);

/**
* @brief validates some simple properties of a transaction
Expand Down
13 changes: 10 additions & 3 deletions src/cryptonote_core/tx_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,17 +666,24 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::get_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) const
bool tx_memory_pool::get_complement(std::vector<crypto::hash> hashes, std::vector<cryptonote::blobdata> &txes) const
{
CRITICAL_REGION_LOCAL(m_transactions_lock);
CRITICAL_REGION_LOCAL1(m_blockchain);

// Sort so we can do binary search later
std::sort(hashes.begin(), hashes.end());

m_blockchain.for_all_txpool_txes([this, &hashes, &txes](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata_ref*) {
const auto tx_relay_method = meta.get_relay_method();
if (tx_relay_method != relay_method::block && tx_relay_method != relay_method::fluff)
return true;
const auto i = std::find(hashes.begin(), hashes.end(), txid);
if (i == hashes.end())

// Do binary search for our pool TXID in given list, skip to next if already present
const auto hash_it = std::lower_bound(hashes.cbegin(), hashes.cend(), txid);
if (hash_it != hashes.cend() && *hash_it == txid)
return true;

{
cryptonote::blobdata bd;
try
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/tx_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ namespace cryptonote
/**
* @brief get transactions not in the passed set
*/
bool get_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) const;
bool get_complement(std::vector<crypto::hash> hashes, std::vector<cryptonote::blobdata> &txes) const;

/**
* @brief get info necessary for update of pool-related info in a wallet, preferably incremental
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_protocol/cryptonote_protocol_handler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ namespace cryptonote
std::vector<cryptonote::blobdata> local_txs;

std::vector<cryptonote::blobdata> txes;
if (!m_core.get_txpool_complement(arg.hashes, txes))
if (!m_core.get_txpool_complement(std::move(arg.hashes), txes))
{
LOG_ERROR_CCONTEXT("failed to get txpool complement");
return 1;
Expand Down