-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add constant-delay worker * Fix docs * Less delay to compensate for 20-chains * Update README and change block-delay flag name
- Loading branch information
1 parent
9ecabec
commit c6a7509
Showing
5 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE NumericUnderscores #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
-- | | ||
-- Module: Worker.ConstantDelay | ||
-- Copyright: Copyright © 2022 Kadena LLC. | ||
-- License: MIT | ||
-- Maintainer: Edmund Noble <[email protected]> | ||
-- Stability: experimental | ||
-- | ||
-- Simulation Mining Worker | ||
-- | ||
-- A fake mining worker that is not actually doing any work. | ||
-- It returns the work bytes unchanged after a constant delay has passed. | ||
-- | ||
module Worker.ConstantDelay (constantDelayWorker) where | ||
|
||
import Control.Concurrent (threadDelay) | ||
|
||
import qualified Data.Text as T | ||
|
||
import Numeric.Natural | ||
|
||
import System.LogLevel | ||
|
||
-- internal modules | ||
|
||
import Logger | ||
import Worker | ||
|
||
-- -------------------------------------------------------------------------- -- | ||
-- Simulation Mining Worker | ||
|
||
-- | A fake mining worker that is not actually doing any work. It returns | ||
-- the work bytes unchanged after a configured time delay passes. | ||
-- | ||
constantDelayWorker :: Logger -> Natural -> Worker | ||
constantDelayWorker logger delay _nonce _target work = do | ||
logg Info $ "solve time (seconds): " <> T.pack (show delay) | ||
threadDelay ((1_000000 * fromIntegral delay) `div` 20) | ||
return work | ||
where | ||
logg = writeLog logger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters