Module darkfi::validator::pow

source ·
Expand description

DarkFi PoW module

Structs§

  • This struct represents the information required by the PoW algorithm

Constants§

  • How many most recent blocks to use to verify new blocks’ timestamp
  • 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
  • Amount of max items(blocks) to use for next difficulty calculation. Must be >= 2 and == BUF_SIZE - DIFFICULTY_LAG.
  • RETAINED 🔒
    Max items to use for next difficulty calculation. Must be DIFFICULTY_WINDOW - 2 * 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.
  • 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§

  • Mine provided block, based on provided PoW module next mine target