| 634 | } |
| 635 | |
| 636 | bool Stake::getPrevBlock(const CBlock curBlock, CBlock &prevBlock, int &nBlockHeight) |
| 637 | { |
| 638 | if (curBlock.vtx.size() < 2) |
| 639 | { |
| 640 | return false; |
| 641 | } |
| 642 | const CTransaction& tx = curBlock.vtx[1]; |
| 643 | if (!tx.IsCoinStake()) |
| 644 | return error("%s: called on non-coinstake %s", __func__, tx.ToString()); |
| 645 | |
| 646 | // Kernel (input 0) must match the stake hash target per coin age (nBits). |
| 647 | const CTxIn& txin = tx.vin[0]; |
| 648 | |
| 649 | // First, try to find the previous transaction in database. |
| 650 | uint256 prevBlockHash; |
| 651 | CTransaction txPrev; |
| 652 | const Consensus::Params& consensusparams = Params().GetConsensus(); |
| 653 | if (!GetTransaction(txin.prevout.hash, txPrev, consensusparams, prevBlockHash, true)) |
| 654 | return error("%s: read txPrev failed", __func__); |
| 655 | |
| 656 | CBlockIndex* pindex = LookupBlockIndex(prevBlockHash); |
| 657 | |
| 658 | if (!pindex) |
| 659 | return error("%s: read block failed", __func__); |
| 660 | |
| 661 | nBlockHeight = pindex->nHeight; |
| 662 | // Read block header. |
| 663 | return ReadBlockFromDisk(prevBlock, pindex->GetBlockPos(), pindex->nHeight, consensusparams); |
| 664 | } |
| 665 | |
| 666 | bool Stake::isSpeedAccepted(CBlock prevBlock, CBlock& prev1Block, int& height, int nBlockHeight,const unsigned ind){ |
| 667 |
nothing calls this directly
no test coverage detected