mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #6478: refactor: add const to llmq_ctx, isman, clhandler in rpc code
5b914fe081
refactor: add const to llmq_ctx, isman, clhandler in rpc code (Konstantin Akimov) Pull request description: ## What was done? Add missing const for all usages of llmq_ctx, llmq_ctx->isman and llmq_ctx->clhandler in rpc code. ## Issue being fixed or feature implemented Added `const` helps to read rpc code to see that none of mentioned objects are actually changed. ## How Has This Been Tested? Run unit and functional tests ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK5b914fe081
PastaPastaPasta: utACK5b914fe081
Tree-SHA512: dfaa99887250638e90f0c87271cf3c70833d4199797050be6a8b84939f78d857419a3e9e3da73035aca10e27782f28f43f156c69380d1c8df892c97c468c76d7
This commit is contained in:
commit
69a2c98c3f
@ -78,7 +78,7 @@ static Mutex cs_blockchange;
|
|||||||
static std::condition_variable cond_blockchange;
|
static std::condition_variable cond_blockchange;
|
||||||
static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange);
|
static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange);
|
||||||
|
|
||||||
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, CTxMemPool& mempool, CChainState& active_chainstate, llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman, UniValue& entry);
|
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry);
|
||||||
|
|
||||||
/* Calculate the difficulty for a given block index.
|
/* Calculate the difficulty for a given block index.
|
||||||
*/
|
*/
|
||||||
@ -127,7 +127,7 @@ static const CBlockIndex* ParseHashOrHeight(const UniValue& param, ChainstateMan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex, llmq::CChainLocksHandler& clhandler)
|
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler)
|
||||||
{
|
{
|
||||||
// Serialize passed information without accessing chain state of the active chain!
|
// Serialize passed information without accessing chain state of the active chain!
|
||||||
AssertLockNotHeld(cs_main); // For performance reasons
|
AssertLockNotHeld(cs_main); // For performance reasons
|
||||||
@ -159,7 +159,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman, bool txDetails)
|
UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, bool txDetails)
|
||||||
{
|
{
|
||||||
UniValue result = blockheaderToJSON(tip, blockindex, clhandler);
|
UniValue result = blockheaderToJSON(tip, blockindex, clhandler);
|
||||||
|
|
||||||
@ -258,8 +258,8 @@ static RPCHelpMan getbestchainlock()
|
|||||||
|
|
||||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
|
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
llmq::CChainLockSig clsig = llmq_ctx.clhandler->GetBestChainLock();
|
const llmq::CChainLockSig clsig = llmq_ctx.clhandler->GetBestChainLock();
|
||||||
if (clsig.IsNull()) {
|
if (clsig.IsNull()) {
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to find any ChainLock");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to find any ChainLock");
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ static RPCHelpMan getbestchainlock()
|
|||||||
result.pushKV("height", clsig.getHeight());
|
result.pushKV("height", clsig.getHeight());
|
||||||
result.pushKV("signature", clsig.getSig().ToString());
|
result.pushKV("signature", clsig.getSig().ToString());
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(node);
|
const ChainstateManager& chainman = EnsureChainman(node);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
result.pushKV("known_block", chainman.m_blockman.LookupBlockIndex(clsig.getBlockHash()) != nullptr);
|
result.pushKV("known_block", chainman.m_blockman.LookupBlockIndex(clsig.getBlockHash()) != nullptr);
|
||||||
return result;
|
return result;
|
||||||
@ -485,7 +485,7 @@ static std::vector<RPCResult> MempoolEntryDescription() { return {
|
|||||||
RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"}
|
RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"}
|
||||||
};}
|
};}
|
||||||
|
|
||||||
static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPoolEntry& e, llmq::CInstantSendManager* isman) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
|
static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPoolEntry& e, const llmq::CInstantSendManager* isman) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
|
||||||
{
|
{
|
||||||
AssertLockHeld(pool.cs);
|
AssertLockHeld(pool.cs);
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
|
|||||||
info.pushKV("unbroadcast", pool.IsUnbroadcastTx(tx.GetHash()));
|
info.pushKV("unbroadcast", pool.IsUnbroadcastTx(tx.GetHash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue MempoolToJSON(const CTxMemPool& pool, llmq::CInstantSendManager* isman, bool verbose, bool include_mempool_sequence)
|
UniValue MempoolToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager* isman, bool verbose, bool include_mempool_sequence)
|
||||||
{
|
{
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
if (include_mempool_sequence) {
|
if (include_mempool_sequence) {
|
||||||
@ -623,7 +623,7 @@ static RPCHelpMan getrawmempool()
|
|||||||
|
|
||||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
const CTxMemPool& mempool = EnsureMemPool(node);
|
const CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
return MempoolToJSON(mempool, llmq_ctx.isman, fVerbose, include_mempool_sequence);
|
return MempoolToJSON(mempool, llmq_ctx.isman, fVerbose, include_mempool_sequence);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -682,7 +682,7 @@ static RPCHelpMan getmempoolancestors()
|
|||||||
return o;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
for (CTxMemPool::txiter ancestorIt : setAncestors) {
|
for (CTxMemPool::txiter ancestorIt : setAncestors) {
|
||||||
const CTxMemPoolEntry &e = *ancestorIt;
|
const CTxMemPoolEntry &e = *ancestorIt;
|
||||||
const uint256& _hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
@ -750,7 +750,7 @@ static RPCHelpMan getmempooldescendants()
|
|||||||
return o;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
for (CTxMemPool::txiter descendantIt : setDescendants) {
|
for (CTxMemPool::txiter descendantIt : setDescendants) {
|
||||||
const CTxMemPoolEntry &e = *descendantIt;
|
const CTxMemPoolEntry &e = *descendantIt;
|
||||||
const uint256& _hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
@ -794,7 +794,7 @@ static RPCHelpMan getmempoolentry()
|
|||||||
|
|
||||||
const CTxMemPoolEntry &e = *it;
|
const CTxMemPoolEntry &e = *it;
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
entryToJSON(mempool, info, e, llmq_ctx.isman);
|
entryToJSON(mempool, info, e, llmq_ctx.isman);
|
||||||
return info;
|
return info;
|
||||||
},
|
},
|
||||||
@ -985,7 +985,7 @@ static RPCHelpMan getblockheader()
|
|||||||
return strHex;
|
return strHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
return blockheaderToJSON(tip, pblockindex, *llmq_ctx.clhandler);
|
return blockheaderToJSON(tip, pblockindex, *llmq_ctx.clhandler);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -1084,7 +1084,7 @@ static RPCHelpMan getblockheaders()
|
|||||||
return arrHeaders;
|
return arrHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
for (; pblockindex; pblockindex = active_chain.Next(pblockindex))
|
for (; pblockindex; pblockindex = active_chain.Next(pblockindex))
|
||||||
{
|
{
|
||||||
arrHeaders.push_back(blockheaderToJSON(tip, pblockindex, *llmq_ctx.clhandler));
|
arrHeaders.push_back(blockheaderToJSON(tip, pblockindex, *llmq_ctx.clhandler));
|
||||||
@ -1305,7 +1305,7 @@ static RPCHelpMan getblock()
|
|||||||
return strHex;
|
return strHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
return blockToJSON(chainman.m_blockman, block, tip, pblockindex, *llmq_ctx.clhandler, *llmq_ctx.isman, verbosity >= 2);
|
return blockToJSON(chainman.m_blockman, block, tip, pblockindex, *llmq_ctx.clhandler, *llmq_ctx.isman, verbosity >= 2);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -1983,7 +1983,7 @@ static RPCHelpMan getchaintips()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue MempoolInfoToJSON(const CTxMemPool& pool, llmq::CInstantSendManager& isman)
|
UniValue MempoolInfoToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager& isman)
|
||||||
{
|
{
|
||||||
// Make sure this call is atomic in the pool.
|
// Make sure this call is atomic in the pool.
|
||||||
LOCK(pool.cs);
|
LOCK(pool.cs);
|
||||||
@ -2029,7 +2029,7 @@ static RPCHelpMan getmempoolinfo()
|
|||||||
{
|
{
|
||||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
const CTxMemPool& mempool = EnsureMemPool(node);
|
const CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
return MempoolInfoToJSON(mempool, *llmq_ctx.isman);
|
return MempoolInfoToJSON(mempool, *llmq_ctx.isman);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -2567,10 +2567,10 @@ static RPCHelpMan getspecialtxes()
|
|||||||
ChainstateManager& chainman = EnsureChainman(node);
|
ChainstateManager& chainman = EnsureChainman(node);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
CTxMemPool& mempool = EnsureMemPool(node);
|
const CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
|
|
||||||
uint256 blockhash(ParseHashV(request.params[0], "blockhash"));
|
const uint256 blockhash(ParseHashV(request.params[0], "blockhash"));
|
||||||
|
|
||||||
int nTxType = -1;
|
int nTxType = -1;
|
||||||
if (!request.params[1].isNull()) {
|
if (!request.params[1].isNull()) {
|
||||||
|
@ -41,16 +41,16 @@ double GetDifficulty(const CBlockIndex* blockindex);
|
|||||||
void RPCNotifyBlockChange(const CBlockIndex*);
|
void RPCNotifyBlockChange(const CBlockIndex*);
|
||||||
|
|
||||||
/** Block description to JSON */
|
/** Block description to JSON */
|
||||||
UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman, bool txDetails = false) LOCKS_EXCLUDED(cs_main);
|
UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, bool txDetails = false) LOCKS_EXCLUDED(cs_main);
|
||||||
|
|
||||||
/** Mempool information to JSON */
|
/** Mempool information to JSON */
|
||||||
UniValue MempoolInfoToJSON(const CTxMemPool& pool, llmq::CInstantSendManager& isman);
|
UniValue MempoolInfoToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager& isman);
|
||||||
|
|
||||||
/** Mempool to JSON */
|
/** Mempool to JSON */
|
||||||
UniValue MempoolToJSON(const CTxMemPool& pool, llmq::CInstantSendManager* isman, bool verbose = false, bool include_mempool_sequence = false);
|
UniValue MempoolToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager* isman, bool verbose = false, bool include_mempool_sequence = false);
|
||||||
|
|
||||||
/** Block header to JSON */
|
/** Block header to JSON */
|
||||||
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex, llmq::CChainLocksHandler& clhandler) LOCKS_EXCLUDED(cs_main);
|
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler) LOCKS_EXCLUDED(cs_main);
|
||||||
|
|
||||||
/** Used by getblockstats to get feerates at different percentiles by weight */
|
/** Used by getblockstats to get feerates at different percentiles by weight */
|
||||||
void CalculatePercentilesBySize(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_size);
|
void CalculatePercentilesBySize(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_size);
|
||||||
|
@ -368,7 +368,7 @@ static RPCHelpMan generateblock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CChainParams chainparams(Params());
|
CChainParams chainparams(Params());
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(node);
|
ChainstateManager& chainman = EnsureChainman(node);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
CChainState& active_chainstate = chainman.ActiveChainstate();
|
||||||
@ -709,7 +709,7 @@ static RPCHelpMan getblocktemplate()
|
|||||||
return "duplicate-inconclusive";
|
return "duplicate-inconclusive";
|
||||||
}
|
}
|
||||||
|
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
|
|
||||||
CBlockIndex* const pindexPrev = active_chain.Tip();
|
CBlockIndex* const pindexPrev = active_chain.Tip();
|
||||||
// TestBlockValidity only supports blocks built on the current Tip
|
// TestBlockValidity only supports blocks built on the current Tip
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, CTxMemPool& mempool, CChainState& active_chainstate, llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman, UniValue& entry)
|
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry)
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
|
|
||||||
@ -269,8 +269,8 @@ static RPCHelpMan getrawtransaction()
|
|||||||
return EncodeHexTx(*tx);
|
return EncodeHexTx(*tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
CTxMemPool& mempool = EnsureMemPool(node);
|
const CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
if (blockindex) result.pushKV("in_active_chain", in_active_chain);
|
if (blockindex) result.pushKV("in_active_chain", in_active_chain);
|
||||||
|
Loading…
Reference in New Issue
Block a user