Skip to content

Commit

Permalink
refactor + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Dec 19, 2023
1 parent a1416bc commit 6e16d19
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,15 @@ static UniValue getassetunlockchainlocks(const JSONRPCRequest& request)
bool chainlock_info = false;
llmq::CChainLockSig bestclsig = llmq_ctx.clhandler->GetBestChainLock();
if (bestclsig.IsNull()) {
// If no CL info is available, try to use CbTx CL information
auto cbtx_best_cl = GetNonNullCoinbaseChainlock(pTipBlockIndex);
if (cbtx_best_cl.has_value()) {
pBlockIndex = pTipBlockIndex->GetAncestor(pTipBlockIndex->nHeight - cbtx_best_cl->second - 1);
chainlock_info = true;
}
else {
// If no CL info available at all, build Credit pool based on Tip but chainlock_info is false.
// Found Asset Unlock indexes will be marked as "mined" instead of "chainlocked"
pBlockIndex = pTipBlockIndex;
}
}
Expand All @@ -405,18 +408,12 @@ static UniValue getassetunlockchainlocks(const JSONRPCRequest& request)
chainlock_info = true;
}

CCreditPool pool;
{
UniValue result(UniValue::VOBJ);
{
LOCK(cs_main);
if (!pBlockIndex) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
pool = node.creditPoolManager->GetCreditPool(pBlockIndex, Params().GetConsensus());
}
if (!pBlockIndex) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not found");
}

CCreditPool pool = node.creditPoolManager->GetCreditPool(pBlockIndex, Params().GetConsensus());

for (const auto i : irange::range(str_indexes.size())) {
UniValue obj(UniValue::VOBJ);
uint64_t index{};
Expand Down

0 comments on commit 6e16d19

Please sign in to comment.