@@ -62,6 +62,7 @@ data CliOptions = CliOptions
6262 , electricity_rate :: Double
6363 , profitability_warning :: Double
6464 , profitability_critical :: Double
65+ , block_fee_average_num :: Integer
6566 , block_reward :: Maybe Double
6667 , mining_fee_reward :: Maybe Double
6768 , pool_fee :: Double
@@ -105,6 +106,8 @@ defaultProfitabilityCriticalThreshold :: Double
105106defaultProfitabilityCriticalThreshold = 0
106107defaultPoolFee :: Double
107108defaultPoolFee = 0
109+ defaultBlockFeeAverageNum :: Integer
110+ defaultBlockFeeAverageNum = 10
108111
109112cliOptions :: Parser CliOptions
110113cliOptions = CliOptions
@@ -277,6 +280,13 @@ cliOptions = CliOptions
277280 <> help " Critical profitability threshold in USD/day"
278281 <> showDefault
279282 )
283+ <*> option auto
284+ ( long " fee_block_average_num"
285+ <> metavar " NUMBER"
286+ <> help " Number of past blocks to use for fee average"
287+ <> value defaultBlockFeeAverageNum
288+ <> showDefault
289+ )
280290 <*> optional (option auto
281291 ( long " block_reward"
282292 <> metavar " NUMBER"
@@ -464,7 +474,7 @@ instance ToPerfData PerfDataWorkMode where
464474
465475-- | Try to parse stats from miner. Return error `T.Text` if for failure.
466476tryCommand :: T. Text -> (ReplyApi -> Either String Stats ) -> CliOptions -> IO (Either T. Text Stats )
467- tryCommand c f (CliOptions h p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) = do
477+ tryCommand c f (CliOptions h p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ) = do
468478 r <- catches (sendCGMinerCommand h p c)
469479 [ Handler (\ (e :: IOException ) ->
470480 error $ " IOException while sending '" ++ T. unpack c ++ " ' command: " ++ show e
@@ -498,7 +508,7 @@ trySummary = tryCommand "summary" getSummary
498508
499509execCheck :: CliOptions -> IO ()
500510execCheck opts@ (CliOptions _ _ tw tc hw hc hmax hirw hirc hu flw flc fhw fhc vhw vhc freqhw
501- freqhc ps mpc erd profw profc mbr mmfr pfp) = do
511+ freqhc ps mpc erd profw profc bfan mbr mmfr pfp) = do
502512 -- Try to get "stats" command first
503513 eStats <- tryStats opts
504514 processStats eStats
@@ -525,7 +535,7 @@ execCheck opts@(CliOptions _ _ tw tc hw hc hmax hirw hirc hu flw flc fhw fhc vhw
525535 getProfitabilityFactors :: IO (Maybe ProfitabilityFactors )
526536 getProfitabilityFactors = do
527537 dNr <- cacheIO " difficultyAndRewardCache" nominalDay getBitcoinDifficultyAndReward
528- mr <- cacheIO " minerFeeRewardCache" nominalDay getBitcoinAverageMiningFeeReward
538+ mr <- cacheIO " minerFeeRewardCache" nominalDay $ getBitcoinAverageMiningFeeReward bfan
529539 p <- cacheIO " priceCache" nominalDay getBitcoinPrice
530540 let er = EnergyRate USD KiloWattHour (toRational erd)
531541 return $ ProfitabilityFactors er <$> (fst <$> dNr) <*> p
0 commit comments