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

Method isSpeedValid

src/stake.cpp:693–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691}
692
693bool Stake::isSpeedValid(uint32_t nTime, CBlock prevBlock, CBlockIndex* pindex, int nBlockHeight)
694{
695 uint32_t prevTime = prevBlock.GetBlockTime();
696 uint32_t nAge = POS_AGE_THRESHOLD + prevTime;
697 int height = 0;
698
699 if (nTime < nAge) {
700 pos_debug("POS: ++++++++++++++++++++++++++++++++++++++++++++++\n");
701 pos_debug("POS: current block = %u timestamp = %u (%s) \n", nBlockHeight, nTime, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTime).c_str());
702 pos_debug("POS: Previous block = %u timestamp = %u (%s) \n", pindex->nHeight, prevTime, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", prevTime).c_str());
703
704
705 // Current PoS block seems to be faster than usual.
706 // Check the last three prev block from current UTXO/address
707 // if it's still faster. Reject current block.
708 CBlock prev1Block, prev2Block, prev3Block;
709 if(!isSpeedAccepted(prevBlock,prev1Block, height, nBlockHeight, 1))
710 return false;
711
712 if(!isSpeedAccepted(prev1Block,prev2Block, height, nBlockHeight, 2))
713 return false;
714
715 if(!isSpeedAccepted(prev2Block,prev3Block, height, nBlockHeight, 3))
716 return false;
717
718 pos_debug("POS: Block %u is accepted\n", nBlockHeight);
719 }
720
721 return true;
722}
723
724#ifdef POS_DEBUG
725long PoSTotal = 0;

Callers

nothing calls this directly

Calls 2

DateTimeStrFormatFunction · 0.85
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected