Skip to content

Commit

Permalink
refactor: make GetCoinbaseTx static function, remove from global name…
Browse files Browse the repository at this point in the history
…space
  • Loading branch information
knst committed Oct 31, 2024
1 parent 50ea5e1 commit d99c14a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 5 additions & 10 deletions src/evo/cbtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <deploymentstatus.h>
#include <validation.h>


bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state)
{
if (tx.nType != TRANSACTION_COINBASE) {
Expand Down Expand Up @@ -448,7 +449,7 @@ std::string CCbTx::ToString() const
creditPoolBalance / COIN, creditPoolBalance % COIN);
}

std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex)
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
{
if (pindex == nullptr) {
return std::nullopt;
Expand All @@ -464,20 +465,14 @@ std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex)
return std::nullopt;
}

CTransactionRef cbTx = block.vtx[0];
return GetTxPayload<CCbTx>(*cbTx);
}

std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
{
auto opt_cbtx = GetCoinbaseTx(pindex);
const CTransactionRef cbTx = block.vtx[0];
const auto opt_cbtx = GetTxPayload<CCbTx>(*cbTx);

if (!opt_cbtx.has_value()) {
return std::nullopt;
}

CCbTx& cbtx = opt_cbtx.value();

const CCbTx& cbtx = opt_cbtx.value();
if (cbtx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) {
return std::nullopt;
}
Expand Down
1 change: 0 additions & 1 deletion src/evo/cbtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ bool CheckCbTxBestChainlock(const CBlock& block, const CBlockIndex* pindexPrev,
bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, const CBlockIndex* pindexPrev,
uint32_t& bestCLHeightDiff, CBLSSignature& bestCLSignature);

std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex);
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex);

#endif // BITCOIN_EVO_CBTX_H

0 comments on commit d99c14a

Please sign in to comment.