Skip to content

Commit

Permalink
Merge pull request #52 from BlockMechanic/segwit
Browse files Browse the repository at this point in the history
Crash tracing
  • Loading branch information
BlockMechanic authored Apr 9, 2022
2 parents 3e8a6ac + 2a92178 commit ffe65db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/crown/nodewallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,20 @@ bool NodeWallet::CreateCoinStake(const int nHeight, const uint32_t& nBits, const
template <typename stakingnode>
bool GetPointers(stakingnode* pstaker, std::vector<StakePointer>& vStakePointers, int nPaymentSlot)
{
LogPrintf("%s: 1\n", __func__);
bool found = false;
// get block index of last mn payment
std::vector<const CBlockIndex*> vBlocksLastPaid;
if (!pstaker->GetRecentPaymentBlocks(vBlocksLastPaid, false)) {
LogPrintf("GetRecentStakePointer -- Couldn't find last paid block\n");
return false;
}

LogPrintf("%s: 2\n", __func__);
int nBestHeight = ::ChainActive().Height();
for (auto pindex : vBlocksLastPaid) {
if (budget.IsBudgetPaymentBlock(pindex->nHeight))
continue;
LogPrintf("%s: 2.1\n", __func__);

// Pointer has to be at least deeper than the max reorg depth
const int nMaxReorganizationDepth = 100;
Expand All @@ -256,16 +258,23 @@ bool GetPointers(stakingnode* pstaker, std::vector<StakePointer>& vStakePointers
LogPrintf("GetRecentStakePointer -- Failed reading block from disk\n");
return false;
}
LogPrintf("%s: 2.2\n", __func__);

CScript scriptMNPubKey;
scriptMNPubKey = GetScriptForDestination(PKHash(pstaker->pubkey));
LogPrintf("%s: 2.3\n", __func__);

for (auto& tx : blockLastPaid.vtx) {
LogPrintf("%s: 2.4.0\n", __func__);

auto stakeSource = COutPoint(tx->GetHash(), nPaymentSlot);
uint256 hashPointer = stakeSource.GetHash();
if (mapUsedStakePointers.count(hashPointer))
continue;
LogPrintf("%s: %s\n", __func__, tx->ToString());

CTxOutAsset mout = (tx->nVersion >= TX_ELE_VERSION ? tx->vpout[nPaymentSlot] : tx->vout[nPaymentSlot]);
LogPrintf("%s: 2.4.1\n", __func__);

if (tx->IsCoinBase() && mout.scriptPubKey == scriptMNPubKey) {
StakePointer stakePointer;
Expand All @@ -277,9 +286,11 @@ bool GetPointers(stakingnode* pstaker, std::vector<StakePointer>& vStakePointers
found = true;
continue;
}
LogPrintf("%s: 2.4.2\n", __func__);

}
}

LogPrintf("%s: 3\n", __func__);
return found;
}

Expand Down
2 changes: 1 addition & 1 deletion src/masternode/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) c
LogPrintf("CBudgetManager::FillBlockPayee - Budget payment to %s for %lld; proposal %s\n",
EncodeDestination(ScriptHash(CScriptID(payment.payee))), payment.nAmount, payment.nProposalHash.ToString());
if(txNew.nVersion >= TX_ELE_VERSION)
txNew.vpout.push_back(CTxOut(payment.nAmount, payment.payee));
txNew.vpout.push_back(CTxOutAsset(Params().GetConsensus().subsidy_asset, payment.nAmount, payment.payee));
else
txNew.vout.push_back(CTxOut(payment.nAmount, payment.payee));
}
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc

// Slow down blocks so that the testnet chain does not burn through the stakepointers too quick
if (Params().NetworkIDString() == CBaseChainParams::TESTNET && GetAdjustedTime() - ::ChainActive().Tip()->nTime < 30)
UninterruptibleSleep(std::chrono::milliseconds(3000));
UninterruptibleSleep(std::chrono::milliseconds(30000));

if (currentNode.CreateCoinStake(nHeight, nBits, nTime, txCoinStake, nTxNewTime, stakePointer)) {
pblock->nTime = nTxNewTime;
Expand Down

0 comments on commit ffe65db

Please sign in to comment.