From fad8c36aa9011c3f7b1183f8380577e16a2167a6 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Aug 2023 15:51:00 +0200 Subject: [PATCH] move-only: Create src/kernel/mempool_removal_reason.h This is needed for a future commit. Can be reviewed with: --color-moved=dimmed-zebra --- src/Makefile.am | 3 +++ src/kernel/mempool_removal_reason.cpp | 21 +++++++++++++++++++++ src/kernel/mempool_removal_reason.h | 24 ++++++++++++++++++++++++ src/txmempool.cpp | 13 ------------- src/txmempool.h | 22 ++++------------------ 5 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 src/kernel/mempool_removal_reason.cpp create mode 100644 src/kernel/mempool_removal_reason.h diff --git a/src/Makefile.am b/src/Makefile.am index 1f953ab624..feed4a0061 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -190,6 +190,7 @@ BITCOIN_CORE_H = \ kernel/mempool_limits.h \ kernel/mempool_options.h \ kernel/mempool_persist.h \ + kernel/mempool_removal_reason.h \ kernel/notifications_interface.h \ kernel/validation_cache_sizes.h \ key.h \ @@ -401,6 +402,7 @@ libbitcoin_node_a_SOURCES = \ kernel/context.cpp \ kernel/cs_main.cpp \ kernel/mempool_persist.cpp \ + kernel/mempool_removal_reason.cpp \ mapport.cpp \ net.cpp \ net_processing.cpp \ @@ -940,6 +942,7 @@ libbitcoinkernel_la_SOURCES = \ kernel/context.cpp \ kernel/cs_main.cpp \ kernel/mempool_persist.cpp \ + kernel/mempool_removal_reason.cpp \ key.cpp \ logging.cpp \ node/blockstorage.cpp \ diff --git a/src/kernel/mempool_removal_reason.cpp b/src/kernel/mempool_removal_reason.cpp new file mode 100644 index 0000000000..df27590c7a --- /dev/null +++ b/src/kernel/mempool_removal_reason.cpp @@ -0,0 +1,21 @@ +// Copyright (c) 2016-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://opensource.org/license/mit/. + +#include + +#include +#include + +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept +{ + switch (r) { + case MemPoolRemovalReason::EXPIRY: return "expiry"; + case MemPoolRemovalReason::SIZELIMIT: return "sizelimit"; + case MemPoolRemovalReason::REORG: return "reorg"; + case MemPoolRemovalReason::BLOCK: return "block"; + case MemPoolRemovalReason::CONFLICT: return "conflict"; + case MemPoolRemovalReason::REPLACED: return "replaced"; + } + assert(false); +} diff --git a/src/kernel/mempool_removal_reason.h b/src/kernel/mempool_removal_reason.h new file mode 100644 index 0000000000..53c2ff1c31 --- /dev/null +++ b/src/kernel/mempool_removal_reason.h @@ -0,0 +1,24 @@ +// Copyright (c) 2016-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://opensource.org/license/mit/. + +#ifndef BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H +#define BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H + +#include + +/** Reason why a transaction was removed from the mempool, + * this is passed to the notification signal. + */ +enum class MemPoolRemovalReason { + EXPIRY, //!< Expired from mempool + SIZELIMIT, //!< Removed in size limiting + REORG, //!< Removed for reorganization + BLOCK, //!< Removed for block + CONFLICT, //!< Removed for conflict with in-block transaction + REPLACED, //!< Removed for replacement +}; + +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; + +#endif // BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 497a41d6a9..226dd9f353 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1197,19 +1197,6 @@ void CTxMemPool::SetLoadTried(bool load_tried) m_load_tried = load_tried; } -std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept -{ - switch (r) { - case MemPoolRemovalReason::EXPIRY: return "expiry"; - case MemPoolRemovalReason::SIZELIMIT: return "sizelimit"; - case MemPoolRemovalReason::REORG: return "reorg"; - case MemPoolRemovalReason::BLOCK: return "block"; - case MemPoolRemovalReason::CONFLICT: return "conflict"; - case MemPoolRemovalReason::REPLACED: return "replaced"; - } - assert(false); -} - std::vector CTxMemPool::GatherClusters(const std::vector& txids) const { AssertLockHeld(cs); diff --git a/src/txmempool.h b/src/txmempool.h index afaaf0d4d6..869612a4a2 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -6,14 +6,14 @@ #ifndef BITCOIN_TXMEMPOOL_H #define BITCOIN_TXMEMPOOL_H -#include -#include - #include #include #include #include -#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export #include #include #include @@ -225,20 +225,6 @@ struct TxMempoolInfo int64_t nFeeDelta; }; -/** Reason why a transaction was removed from the mempool, - * this is passed to the notification signal. - */ -enum class MemPoolRemovalReason { - EXPIRY, //!< Expired from mempool - SIZELIMIT, //!< Removed in size limiting - REORG, //!< Removed for reorganization - BLOCK, //!< Removed for block - CONFLICT, //!< Removed for conflict with in-block transaction - REPLACED, //!< Removed for replacement -}; - -std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; - /** * CTxMemPool stores valid-according-to-the-current-best-chain transactions * that may be included in the next block.