Skip to content

Commit bb7fe58

Browse files
kwvgPastaPastaPasta
authored andcommitted
refactor: rename creditPoolManager to cpoolman in NodeContext, fix order
All members within NodeContext are lower-case and the bare pointer should be null'ed before the smart pointer is, doing it in reverse creates a small gap where the bare pointer is directing to freed space.
1 parent 6f08e10 commit bb7fe58

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ void PrepareShutdown(NodeContext& node)
350350
llmq::quorumSnapshotManager.reset();
351351
node.dmnman = nullptr;
352352
deterministicMNManager.reset();
353+
node.cpoolman = nullptr;
353354
creditPoolManager.reset();
354-
node.creditPoolManager = nullptr;
355355
node.mnhf_manager.reset();
356356
node.evodb.reset();
357357
}
@@ -1969,7 +1969,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
19691969
node.dmnman = deterministicMNManager.get();
19701970
creditPoolManager.reset();
19711971
creditPoolManager = std::make_unique<CCreditPoolManager>(*node.evodb);
1972-
node.creditPoolManager = creditPoolManager.get();
1972+
node.cpoolman = creditPoolManager.get();
19731973
llmq::quorumSnapshotManager.reset();
19741974
llmq::quorumSnapshotManager.reset(new llmq::CQuorumSnapshotManager(*node.evodb));
19751975

src/node/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct NodeContext {
7474
std::unique_ptr<CJContext> cj_ctx;
7575
std::unique_ptr<CMNHFManager> mnhf_manager;
7676
std::unique_ptr<LLMQContext> llmq_ctx;
77-
CCreditPoolManager* creditPoolManager{nullptr};
77+
CCreditPoolManager* cpoolman{nullptr};
7878
CDeterministicMNManager* dmnman{nullptr};
7979
CDSTXManager* dstxman{nullptr};
8080
CGovernanceManager* govman{nullptr};

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static UniValue getassetunlockstatuses(const JSONRPCRequest& request)
499499
if (nSpecificCoreHeight.value() < 0 || nSpecificCoreHeight.value() > chainman.ActiveChain().Height()) {
500500
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
501501
}
502-
poolCL = std::make_optional(node.creditPoolManager->GetCreditPool(chainman.ActiveChain()[nSpecificCoreHeight.value()], Params().GetConsensus()));
502+
poolCL = std::make_optional(node.cpoolman->GetCreditPool(chainman.ActiveChain()[nSpecificCoreHeight.value()], Params().GetConsensus()));
503503
}
504504
else {
505505
const auto pBlockIndexBestCL = [&]() -> const CBlockIndex* {
@@ -517,12 +517,12 @@ static UniValue getassetunlockstatuses(const JSONRPCRequest& request)
517517
// We need in 2 credit pools: at tip of chain and on best CL to know if tx is mined or chainlocked
518518
// Sometimes that's two different blocks, sometimes not and we need to initialize 2nd creditPoolManager
519519
poolCL = pBlockIndexBestCL ?
520-
std::make_optional(node.creditPoolManager->GetCreditPool(pBlockIndexBestCL, Params().GetConsensus())) :
520+
std::make_optional(node.cpoolman->GetCreditPool(pBlockIndexBestCL, Params().GetConsensus())) :
521521
std::nullopt;
522522

523523
poolOnTip = [&]() -> std::optional<CCreditPool> {
524524
if (pTipBlockIndex != pBlockIndexBestCL) {
525-
return std::make_optional(node.creditPoolManager->GetCreditPool(pTipBlockIndex, Params().GetConsensus()));
525+
return std::make_optional(node.cpoolman->GetCreditPool(pTipBlockIndex, Params().GetConsensus()));
526526
}
527527
return std::nullopt;
528528
}();

src/test/util/setup_common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
177177
connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
178178
llmq::quorumSnapshotManager.reset(new llmq::CQuorumSnapshotManager(*m_node.evodb));
179179
creditPoolManager = std::make_unique<CCreditPoolManager>(*m_node.evodb);
180-
m_node.creditPoolManager = creditPoolManager.get();
180+
m_node.cpoolman = creditPoolManager.get();
181181
static bool noui_connected = false;
182182
if (!noui_connected) {
183183
noui_connect();
@@ -190,8 +190,8 @@ BasicTestingSetup::~BasicTestingSetup()
190190
{
191191
connman.reset();
192192
llmq::quorumSnapshotManager.reset();
193+
m_node.cpoolman = nullptr;
193194
creditPoolManager.reset();
194-
m_node.creditPoolManager = nullptr;
195195
m_node.mnhf_manager.reset();
196196
m_node.evodb.reset();
197197

0 commit comments

Comments
 (0)