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

Function GetKernelStakeModifier

src/stake.cpp:340–370  ·  view source on GitHub ↗

The stake modifier used to hash for a stake kernel is chosen as the stake modifier about a selection interval later than the coin generating the kernel

Source from the content-addressed store, hash-verified

338// The stake modifier used to hash for a stake kernel is chosen as the stake
339// modifier about a selection interval later than the coin generating the kernel
340bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
341{
342 nStakeModifier = 0;
343 if (!mapBlockIndex.count(hashBlockFrom))
344 return error("GetKernelStakeModifier() : block not indexed");
345
346 const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom];
347 nStakeModifierHeight = pindexFrom->nHeight;
348 nStakeModifierTime = pindexFrom->GetBlockTime();
349
350 const int64_t nSelectionTime = GetSelectionTime();
351 const CBlockIndex* pindex = pindexFrom;
352 CBlockIndex* pindexNext = chainActive[pindexFrom->nHeight + 1];
353
354 // loop to find the stake modifier later by a selection time
355 while (nStakeModifierTime < pindexFrom->GetBlockTime() + nSelectionTime) {
356 if (!pindexNext) {
357 // Should never happen
358 return error("Null pindexNext\n");
359 }
360
361 pindex = pindexNext;
362 pindexNext = chainActive[pindexNext->nHeight + 1];
363 if (pindex->GeneratedStakeModifier()) {
364 nStakeModifierHeight = pindex->nHeight;
365 nStakeModifierTime = pindex->GetBlockTime();
366 }
367 }
368 nStakeModifier = pindex->nStakeModifier;
369 return true;
370}
371#endif
372
373bool MultiplyStakeTarget(uint256& bnTarget, int nModifierHeight, int64_t nModifierTime, int64_t nWeight) {

Callers 1

CheckHashNewMethod · 0.85

Calls 6

errorFunction · 0.85
GetSelectionTimeFunction · 0.85
GetLuxStakeKernelFunction · 0.85
countMethod · 0.45
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected