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

Method getPrevBlock

src/stake.cpp:636–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634}
635
636bool 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
666bool Stake::isSpeedAccepted(CBlock prevBlock, CBlock& prev1Block, int& height, int nBlockHeight,const unsigned ind){
667

Callers

nothing calls this directly

Calls 9

errorFunction · 0.85
GetTransactionFunction · 0.85
LookupBlockIndexFunction · 0.85
ReadBlockFromDiskFunction · 0.85
GetBlockPosMethod · 0.80
ParamsClass · 0.70
sizeMethod · 0.45
IsCoinStakeMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected