Bitcoin ABC  0.22.12
P2P Digital Currency
Functions | Variables
aserti32d.cpp File Reference
#include <pow/aserti32d.h>
#include <chain.h>
#include <consensus/activation.h>
#include <consensus/params.h>
#include <validation.h>
#include <atomic>
Include dependency graph for aserti32d.cpp:

Go to the source code of this file.

Functions

void ResetASERTAnchorBlockCache () noexcept
 ASERT caches a special block index for efficiency. More...
 
const CBlockIndexGetASERTAnchorBlockCache () noexcept
 
static const CBlockIndexGetASERTAnchorBlock (const CBlockIndex *const pindex, const Consensus::Params &params)
 Returns a pointer to the anchor block used for ASERT. More...
 
uint32_t GetNextASERTWorkRequired (const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params &params) noexcept
 
uint32_t GetNextASERTWorkRequired (const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params &params, const CBlockIndex *pindexAnchorBlock) noexcept
 Compute the next required proof of work using an absolutely scheduled exponentially weighted target (ASERT). More...
 
arith_uint256 CalculateASERT (const arith_uint256 &refTarget, const int64_t nPowTargetSpacing, const int64_t nTimeDiff, const int64_t nHeightDiff, const arith_uint256 &powLimit, const int64_t nHalfLife) noexcept
 

Variables

static std::atomic< const CBlockIndex * > cachedAnchor {nullptr}
 

Function Documentation

◆ CalculateASERT()

arith_uint256 CalculateASERT ( const arith_uint256 refTarget,
const int64_t  nPowTargetSpacing,
const int64_t  nTimeDiff,
const int64_t  nHeightDiff,
const arith_uint256 powLimit,
const int64_t  nHalfLife 
)
noexcept

Definition at line 164 of file aserti32d.cpp.

Here is the caller graph for this function:

◆ GetASERTAnchorBlock()

static const CBlockIndex* GetASERTAnchorBlock ( const CBlockIndex *const  pindex,
const Consensus::Params params 
)
static

Returns a pointer to the anchor block used for ASERT.

As anchor we use the first block for which IsAxionEnabled() returns true. This block happens to be the last block which was mined under the old DAA rules.

This function is meant to be removed some time after the upgrade, once the anchor block is deeply buried, and behind a hard-coded checkpoint.

Preconditions: - pindex must not be nullptr

  • pindex must satisfy: IsAxionEnabled(params, pindex) == true Postcondition: Returns a pointer to the first (lowest) block for which IsAxionEnabled is true, and for which IsAxionEnabled(pprev) is false (or for which pprev is nullptr). The return value may be pindex itself.

Definition at line 39 of file aserti32d.cpp.

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

◆ GetASERTAnchorBlockCache()

const CBlockIndex* GetASERTAnchorBlockCache ( )
noexcept

Definition at line 19 of file aserti32d.cpp.

Here is the caller graph for this function:

◆ GetNextASERTWorkRequired() [1/2]

uint32_t GetNextASERTWorkRequired ( const CBlockIndex pindexPrev,
const CBlockHeader pblock,
const Consensus::Params params 
)
noexcept

Definition at line 90 of file aserti32d.cpp.

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

◆ GetNextASERTWorkRequired() [2/2]

uint32_t GetNextASERTWorkRequired ( const CBlockIndex pindexPrev,
const CBlockHeader pblock,
const Consensus::Params params,
const CBlockIndex pindexAnchorBlock 
)
noexcept

Compute the next required proof of work using an absolutely scheduled exponentially weighted target (ASERT).

With ASERT, we define an ideal schedule for block issuance (e.g. 1 block every 600 seconds), and we calculate the difficulty based on how far the most recent block's timestamp is ahead of or behind that schedule. We set our targets (difficulty) exponentially. For every [nHalfLife] seconds ahead of or behind schedule we get, we double or halve the difficulty.

Definition at line 108 of file aserti32d.cpp.

Here is the call graph for this function:

◆ ResetASERTAnchorBlockCache()

void ResetASERTAnchorBlockCache ( )
noexcept

ASERT caches a special block index for efficiency.

If block indices are freed then this needs to be called to ensure no dangling pointer when a new block tree is created. (this is temporary and will be removed after the ASERT constants are fixed)

Definition at line 15 of file aserti32d.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ cachedAnchor

std::atomic<const CBlockIndex *> cachedAnchor {nullptr}
static

Definition at line 13 of file aserti32d.cpp.