Skip to content

Commit fad8c36

Browse files
author
MarcoFalke
committed
move-only: Create src/kernel/mempool_removal_reason.h
This is needed for a future commit. Can be reviewed with: --color-moved=dimmed-zebra
1 parent fa57608 commit fad8c36

File tree

5 files changed

+52
-31
lines changed

5 files changed

+52
-31
lines changed

src/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ BITCOIN_CORE_H = \
190190
kernel/mempool_limits.h \
191191
kernel/mempool_options.h \
192192
kernel/mempool_persist.h \
193+
kernel/mempool_removal_reason.h \
193194
kernel/notifications_interface.h \
194195
kernel/validation_cache_sizes.h \
195196
key.h \
@@ -401,6 +402,7 @@ libbitcoin_node_a_SOURCES = \
401402
kernel/context.cpp \
402403
kernel/cs_main.cpp \
403404
kernel/mempool_persist.cpp \
405+
kernel/mempool_removal_reason.cpp \
404406
mapport.cpp \
405407
net.cpp \
406408
net_processing.cpp \
@@ -940,6 +942,7 @@ libbitcoinkernel_la_SOURCES = \
940942
kernel/context.cpp \
941943
kernel/cs_main.cpp \
942944
kernel/mempool_persist.cpp \
945+
kernel/mempool_removal_reason.cpp \
943946
key.cpp \
944947
logging.cpp \
945948
node/blockstorage.cpp \

src/kernel/mempool_removal_reason.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2016-present The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or https://opensource.org/license/mit/.
4+
5+
#include <kernel/mempool_removal_reason.h>
6+
7+
#include <cassert>
8+
#include <string>
9+
10+
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept
11+
{
12+
switch (r) {
13+
case MemPoolRemovalReason::EXPIRY: return "expiry";
14+
case MemPoolRemovalReason::SIZELIMIT: return "sizelimit";
15+
case MemPoolRemovalReason::REORG: return "reorg";
16+
case MemPoolRemovalReason::BLOCK: return "block";
17+
case MemPoolRemovalReason::CONFLICT: return "conflict";
18+
case MemPoolRemovalReason::REPLACED: return "replaced";
19+
}
20+
assert(false);
21+
}

src/kernel/mempool_removal_reason.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2016-present The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or https://opensource.org/license/mit/.
4+
5+
#ifndef BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H
6+
#define BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H
7+
8+
#include <string>
9+
10+
/** Reason why a transaction was removed from the mempool,
11+
* this is passed to the notification signal.
12+
*/
13+
enum class MemPoolRemovalReason {
14+
EXPIRY, //!< Expired from mempool
15+
SIZELIMIT, //!< Removed in size limiting
16+
REORG, //!< Removed for reorganization
17+
BLOCK, //!< Removed for block
18+
CONFLICT, //!< Removed for conflict with in-block transaction
19+
REPLACED, //!< Removed for replacement
20+
};
21+
22+
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
23+
24+
#endif // BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H

src/txmempool.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,19 +1197,6 @@ void CTxMemPool::SetLoadTried(bool load_tried)
11971197
m_load_tried = load_tried;
11981198
}
11991199

1200-
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept
1201-
{
1202-
switch (r) {
1203-
case MemPoolRemovalReason::EXPIRY: return "expiry";
1204-
case MemPoolRemovalReason::SIZELIMIT: return "sizelimit";
1205-
case MemPoolRemovalReason::REORG: return "reorg";
1206-
case MemPoolRemovalReason::BLOCK: return "block";
1207-
case MemPoolRemovalReason::CONFLICT: return "conflict";
1208-
case MemPoolRemovalReason::REPLACED: return "replaced";
1209-
}
1210-
assert(false);
1211-
}
1212-
12131200
std::vector<CTxMemPool::txiter> CTxMemPool::GatherClusters(const std::vector<uint256>& txids) const
12141201
{
12151202
AssertLockHeld(cs);

src/txmempool.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#ifndef BITCOIN_TXMEMPOOL_H
77
#define BITCOIN_TXMEMPOOL_H
88

9-
#include <kernel/mempool_limits.h>
10-
#include <kernel/mempool_options.h>
11-
129
#include <coins.h>
1310
#include <consensus/amount.h>
1411
#include <indirectmap.h>
1512
#include <kernel/cs_main.h>
16-
#include <kernel/mempool_entry.h>
13+
#include <kernel/mempool_entry.h> // IWYU pragma: export
14+
#include <kernel/mempool_limits.h> // IWYU pragma: export
15+
#include <kernel/mempool_options.h> // IWYU pragma: export
16+
#include <kernel/mempool_removal_reason.h> // IWYU pragma: export
1717
#include <policy/feerate.h>
1818
#include <policy/packages.h>
1919
#include <primitives/transaction.h>
@@ -225,20 +225,6 @@ struct TxMempoolInfo
225225
int64_t nFeeDelta;
226226
};
227227

228-
/** Reason why a transaction was removed from the mempool,
229-
* this is passed to the notification signal.
230-
*/
231-
enum class MemPoolRemovalReason {
232-
EXPIRY, //!< Expired from mempool
233-
SIZELIMIT, //!< Removed in size limiting
234-
REORG, //!< Removed for reorganization
235-
BLOCK, //!< Removed for block
236-
CONFLICT, //!< Removed for conflict with in-block transaction
237-
REPLACED, //!< Removed for replacement
238-
};
239-
240-
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
241-
242228
/**
243229
* CTxMemPool stores valid-according-to-the-current-best-chain transactions
244230
* that may be included in the next block.

0 commit comments

Comments
 (0)