Bitcoin ABC 0.30.5
P2P Digital Currency
Namespaces | Functions | Variables
grasberg.cpp File Reference
#include <pow/grasberg.h>
#include <arith_uint256.h>
#include <chain.h>
#include <chainparams.h>
#include <consensus/params.h>
Include dependency graph for grasberg.cpp:

Go to the source code of this file.

Namespaces

namespace  grasberg
 

Functions

static arith_uint256 ComputeNextTarget (const CBlockIndex *pindexTip, const CBlockIndex *pindexRef, const CChainParams &params)
 
uint32_t GetNextGrasbergWorkRequired (const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const CChainParams &chainParams)
 Compute the next required proof of work using a relative target based ASERT algorithm. More...
 
int64_t grasberg::computeTargetBlockTime (const CBlockIndex *pindexPrev, const CChainParams &chainParams)
 Compute the block time we are aiming for. More...
 
uint32_t grasberg::deterministicExp2 (const uint32_t n)
 Computes exp2(n) = 2^32 * (2^(n/2^32) - 1) More...
 

Variables

static constexpr int64_t LN2_32 = 2977044472
 
static constexpr int64_t POW2_32 = int64_t(1) << 32
 

Function Documentation

◆ ComputeNextTarget()

static arith_uint256 ComputeNextTarget ( const CBlockIndex pindexTip,
const CBlockIndex pindexRef,
const CChainParams params 
)
static

Even though the correct thing to do would be to add 1 to the target, and then remove 1 at the end, experimentation showed that the cases in which the results differ are vanishingly few and we therefore skip this step.

Definition at line 19 of file grasberg.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextGrasbergWorkRequired()

uint32_t GetNextGrasbergWorkRequired ( const CBlockIndex pindexPrev,
const CBlockHeader pblock,
const CChainParams chainParams 
)

Compute the next required proof of work using a relative target based ASERT algorithm.

This algorithm uses the relative formulation of ASERT in order to allow for activation at any point in time without complications.

In addition, this algorithm contains a drift correction mechanism. While ASERT by itself drifts very little, the chain is already off schedule.

Definition at line 71 of file grasberg.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ LN2_32

constexpr int64_t LN2_32 = 2977044472
staticconstexpr

Definition at line 15 of file grasberg.cpp.

◆ POW2_32

constexpr int64_t POW2_32 = int64_t(1) << 32
staticconstexpr

Definition at line 17 of file grasberg.cpp.