Skip to main content

execute_proof_of_work

Function execute_proof_of_work 

Source
pub fn execute_proof_of_work(
    start_nonce: i64,
    nonce_increment: i64,
    config: &PoWConfig,
    progress_callback: Option<&dyn Fn(u64)>,
    challenge: &IronShieldChallenge,
) -> Result<IronShieldChallengeResponse, String>
Expand description

Proof-of-work function that handles both worker coordination and single-threaded fallback modes.

§Arguments

  • start_nonce: Starting nonce value (0 for single-threaded, offset for worker coordination).
  • nonce_increment: How much to increment nonce each iteration (1 for single-threaded, stride for workers).
  • config: PoWConfig containing max_attempts and progress_reporting_interval.
  • progress_callback: Optional callback for progress reporting.
  • challenge: Original challenge for constructing the response.

§Returns

  • Result<IronShieldChallengeResponse, String>: Ok(IronShieldChallengeResponse) that contains the successful nonce, or an error (Err(String)) message if no solution is found within config.max_attempts.