Module pow

Module pow 

Source
Expand description

DarkFi PoW module

Structsยง

PoWModule
This struct represents the information required by the PoW algorithm

Constantsยง

BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW ๐Ÿ”’
How many most recent blocks to use to verify new blocksโ€™ timestamp
BLOCK_FUTURE_TIME_LIMIT ๐Ÿ”’
Time limit in the future of what blocks can be
BUF_SIZE ๐Ÿ”’
Ring buffer length. Must be == DIFFICULTY_WINDOW + DIFFICULTY_LAG
CUT_BEGIN ๐Ÿ”’
Already known cutoff start index for this config
CUT_END ๐Ÿ”’
Already known cutoff end index for this config
DIFFICULTY_WINDOW ๐Ÿ”’
Amount of max items(blocks) to use for next difficulty calculation. Must be >= 2 and == BUF_SIZE - DIFFICULTY_LAG.
RANDOMX_KEY_CHANGE_DELAY
RandomX VM key change delay
RANDOMX_KEY_CHANGING_HEIGHT
RandomX VM key changing height
RETAINED ๐Ÿ”’
Max items to use for next difficulty calculation. Must be DIFFICULTY_WINDOW - 2 * DIFFICULTY_CUT
_DIFFICULTY_CUT ๐Ÿ”’
Used to calculate how many items to retain for next difficulty calculation. We are keeping the middle items, meaning cutting both from frond and back of the ring buffer, ending up with max DIFFICULTY_WINDOW - 2DIFFICULTY_CUT items. (2DIFFICULTY_CUT <= DIFFICULTY_WINDOW-2) must be true.
_DIFFICULTY_LAG ๐Ÿ”’
Amount of latest blocks to exlude from the calculation. Our ring buffer has length: DIFFICULTY_WINDOW + DIFFICULTY_LAG, but we only use DIFFICULTY_WINDOW items in calculations. Must be == BUF_SIZE - DIFFICULTY_WINDOW.

Functionsยง

generate_mining_vms
Auxiliary function to generate mining VMs for provided RandomX key.
get_mining_flags
Auxiliary function to define RandomXFlags used in mining.
init_dataset ๐Ÿ”’
Auxiliary function to initialize a RandomXDataset using all available threads.
mine_block
Mine provided header, based on provided PoW module next mine target, using provided RandomX VMs setup.