ComputeNextStakeModifier function

From Peercoin Wiki
Jump to: navigation, search

Source code

The ComputeNextStakeModifier function code can be found in the kernel.cpp file (v0.4.0ppc).

Description

Stake Modifier (hash modifier of proof-of-stake):

The purpose of stake modifier is to prevent a txout (coin) owner from computing future proof-of-stake generated by this txout at the time of transaction confirmation. To meet kernel protocol, the txout must hash with a future stake modifier to generate the proof.

Stake modifier consists of bits each of which is contributed from a selected block of a given block group in the past.

The selection of a block is based on a hash of the block's proof-hash and the previous stake modifier.

Stake modifier is recomputed at a fixed time interval instead of every block. This is to make it difficult for an attacker to gain control of additional bits in the stake modifier, even after generating a chain of blocks.

Signature

Parameters

Name Type Description
pindexCurrent const CBlockIndex*
nStakeModifier uint64& The returned stake modifier
fGeneratedStakeModifier bool& The returned stake generated flag

Return value

Type Description
bool true if stake modifier was successfully generated, otherwise false

FAQ

What is the GetLastStakeModifier function and what is it used for?
The GetLastStakeModifier function is described in detail here
What is the GetStakeModifierSelectionInterval function and what is it used for?
The GetStakeModifierSelectionInterval function is described in detail here
What is the SelectBlockFromCandidates function and what is it used for?
The SelectBlockFromCandidates function is described in detail here

Feel free to add your own questions in this FAQ

Links