Skip to content

Commit

Permalink
feat: rpc submitchainlock short circuit if possible and always return…
Browse files Browse the repository at this point in the history
… best height
  • Loading branch information
PastaPastaPasta committed Jan 9, 2024
1 parent 8be260a commit 2292f73
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rpc/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,21 +1017,23 @@ static UniValue submitchainlock(const JSONRPCRequest& request)
if (nBlockHeight <= 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid block height");
}
const LLMQContext& llmq_ctx = EnsureLLMQContext(EnsureAnyNodeContext(request.context));
const int32_t bestCLHeight = llmq_ctx.clhandler->GetBestChainLock().getHeight();
if (nBlockHeight <= bestCLHeight) return bestCLHeight;

CBLSSignature sig;
if (!sig.SetHexStr(request.params[1].get_str(), false) && !sig.SetHexStr(request.params[1].get_str(), true)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid signature format");
}


const LLMQContext& llmq_ctx = EnsureLLMQContext(EnsureAnyNodeContext(request.context));
auto clsig = llmq::CChainLockSig(nBlockHeight, nBlockHash, sig);
if (!llmq_ctx.clhandler->VerifyChainLock(clsig)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid signature");
}

llmq_ctx.clhandler->ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig));
return true;
return llmq_ctx.clhandler->GetBestChainLock().getHeight();
}


Expand Down

0 comments on commit 2292f73

Please sign in to comment.