MCPcopy Create free account
hub / github.com/LUX-Core/lux / ProcessBlockFound

Function ProcessBlockFound

src/miner.cpp:1119–1151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1117}
1118
1119bool ProcessBlockFound(CBlock* pblock, CWallet& wallet)
1120{
1121 // Found a solution (stake)
1122 {
1123 LOCK(cs_main);
1124 if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
1125 return error("LUXMiner : generated block is stale");
1126
1127 for(const CTxIn& vin : pblock->vtx[1].vin) {
1128 if (wallet.IsSpent(vin.prevout.hash, vin.prevout.n)) {
1129 return error("LUXMiner : Gen block stake is invalid - UTXO spent");
1130 }
1131 }
1132 }
1133
1134 CAmount generated = GetProofOfStakeReward(0, chainActive.Height()+1);
1135 generated -= GetMasternodePosReward(chainActive.Height()+1, generated);
1136 LogPrintf("generated %s\n", FormatMoney(generated));
1137
1138 // Process this block the same as if we had received it from another node
1139 const CChainParams& chainParams = Params();
1140 CValidationState state;
1141 if (!ProcessNewBlock(state, chainParams, NULL, pblock)) {
1142 return error("LUXMiner : ProcessNewBlock, block not accepted");
1143 }
1144
1145 {
1146 LOCK(stake->stakeMiner.lock);
1147 stake->stakeMiner.nBlocksAccepted++;
1148 }
1149
1150 return true;
1151}

Callers 1

GenBlockStakeMethod · 0.85

Calls 10

errorFunction · 0.85
GetProofOfStakeRewardFunction · 0.85
GetMasternodePosRewardFunction · 0.85
FormatMoneyFunction · 0.85
ProcessNewBlockFunction · 0.85
TipMethod · 0.80
HeightMethod · 0.80
ParamsClass · 0.70
GetBlockHashMethod · 0.45
IsSpentMethod · 0.45

Tested by

no test coverage detected