Author

Topic: to fix mining profit calculator code (Read 615 times)

newbie
Activity: 42
Merit: 0
May 29, 2013, 05:17:07 PM
#3
Sorry I cant help you here.
newbie
Activity: 26
Merit: 0
May 29, 2013, 11:11:43 AM
#2
plz help me.
newbie
Activity: 26
Merit: 0
May 28, 2013, 05:50:29 AM
#1
hey guys.
I've hired one php coder for mining profit calculator code.

but here got a problem from difficulty increment factor.

When a difficulty increment factor exists like every 14 days the difficulty getting increased 10% around, the earned BTC should be decreased as time goes by, then the BTC earning graph looks like curve, 
but my existing code, it shows a exponentially increased BTC earning.

Can someone help me to fix this code ?

$DifficultIncrementPer value is % one, it used to re-calculate the difficulty of next 14days as my code is shown below

Code:
$Difficulty = (isset($_REQUEST['difficulty']) ? $_REQUEST['difficulty'] : '');
$HashRate = (isset($_REQUEST['hash_rate']) ? $_REQUEST['hash_rate'] : '500');
$TimeFrame = (isset($_REQUEST['time_frame']) ? $_REQUEST['time_frame'] : '30'); // user input timeFrame
$DifficultIncrementPer = (isset($_REQUEST['diff_increment']) ? $_REQUEST['diff_increment'] : '8');  // % per every two weeks
$HashRate = ($HashRate * pow(10,6));  //mhash
$TimeArray = array($TimeFrame,"1","30","180","365");  // user timeframe,  default timeframe (1, 30, 180, 365)
$SecforBlockCurrentDiff = $Difficulty * pow(2,32) / $HashRate; 
$SecforBlockNext14dayDiff = (($Difficulty*(100+$DifficultIncrementPer)/100) * pow(2,32) / $HashRate);


if($TimeArray[$k] <= 14)
{
$BTCEarnedPrev = round((($TimeArray[$k]*25)*(60*60*24)/$SecforBlockCurrentDiff),8);  // 24hours based BTC

}
else
{

$CalcTimeFrameContent = floor(($TimeArray[$k]-14) / 14);
$BalanceTimeFrame = $TimeArray[$k] - (($CalcTimeFrameContent*14)+14);
$BTCEarnedPrev = ((14*25)*(60*60*24)/$SecforBlockCurrentDiff);

for($i=1;$i <= $CalcTimeFrameContent;$i++){

$BTCEarnedPrev += ((14*$i*25)*(60*60*24)/$SecforBlockNext14dayDiff);
}

if($BalanceTimeFrame >= 1){

$BTCEarnedPrev += (($BalanceTimeFrame*25)*(60*60*24)/$SecforBlockNext14dayDiff);

}
}
Jump to: