| 316 | } |
| 317 | |
| 318 | static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) |
| 319 | { |
| 320 | LogPrintf("%s\n", pblock->ToString()); |
| 321 | LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue)); |
| 322 | |
| 323 | // Found a solution |
| 324 | { |
| 325 | LOCK(cs_main); |
| 326 | if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash()) |
| 327 | return error("BitcoinMiner: generated block is stale"); |
| 328 | } |
| 329 | |
| 330 | // Remove key from key pool |
| 331 | reservekey.KeepKey(); |
| 332 | |
| 333 | // Track how many getdata requests this block gets |
| 334 | { |
| 335 | LOCK(wallet.cs_wallet); |
| 336 | wallet.mapRequestCount[pblock->GetHash()] = 0; |
| 337 | } |
| 338 | |
| 339 | // Process this block the same as if we had received it from another node |
| 340 | CValidationState state; |
| 341 | if (!ProcessNewBlock(state, BlockSource{}, pblock, true, NULL)) |
| 342 | return error("BitcoinMiner: ProcessNewBlock, block not accepted"); |
| 343 | |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | void static BitcoinMiner(CWallet *pwallet) |
| 348 | { |
no test coverage detected