Skip to content

Commit fab80fe

Browse files
author
MarcoFalke
committed
refactor: Remove unused EnsureChainman
1 parent fa34587 commit fab80fe

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <txmempool.h>
5151
#include <ui_interface.h>
5252
#include <util/asmap.h>
53+
#include <util/check.h>
5354
#include <util/moneystr.h>
5455
#include <util/string.h>
5556
#include <util/system.h>
@@ -1377,9 +1378,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node)
13771378
node.mempool = &::mempool;
13781379
assert(!node.chainman);
13791380
node.chainman = &g_chainman;
1380-
ChainstateManager& chainman = EnsureChainman(node);
1381+
ChainstateManager& chainman = *Assert(node.chainman);
13811382

1382-
node.peer_logic.reset(new PeerLogicValidation(node.connman.get(), node.banman.get(), *node.scheduler, *node.chainman, *node.mempool));
1383+
node.peer_logic.reset(new PeerLogicValidation(node.connman.get(), node.banman.get(), *node.scheduler, chainman, *node.mempool));
13831384
RegisterValidationInterface(node.peer_logic.get());
13841385

13851386
// sanitize comments per BIP-0014, format user agent and check total size

src/node/context.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,4 @@ struct NodeContext {
4949
~NodeContext();
5050
};
5151

52-
inline ChainstateManager& EnsureChainman(const NodeContext& node)
53-
{
54-
assert(node.chainman);
55-
return *node.chainman;
56-
}
57-
5852
#endif // BITCOIN_NODE_CONTEXT_H

src/rpc/blockchain.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ CTxMemPool& EnsureMemPool(const util::Ref& context)
7575
ChainstateManager& EnsureChainman(const util::Ref& context)
7676
{
7777
NodeContext& node = EnsureNodeContext(context);
78-
return EnsureChainman(node);
78+
if (!node.chainman) {
79+
throw JSONRPCError(RPC_INTERNAL_ERROR, "Node chainman not found");
80+
}
81+
return *node.chainman;
7982
}
8083

8184
/* Calculate the difficulty for a given block index.

0 commit comments

Comments
 (0)