-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate blocktime and block rewards dynamically, other changes
- Loading branch information
Showing
5 changed files
with
96 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
<?php | ||
class calculator | ||
{ | ||
function averageArray($array) { | ||
$sum=0; | ||
foreach ($array as $value) { | ||
$sum += $value; | ||
} | ||
return $sum/count($array); | ||
} | ||
|
||
function calculatePoWCoinsByDifficulty($hashrate, $difficulty) { | ||
{ | ||
function calculatePoWCoinsByDifficulty($hashrate, $difficulty, $blockreward, $timeperiod=86400) { | ||
if ($hashrate == 0) { | ||
return 0; | ||
} else { | ||
return (86400/($difficulty*2**32/$hashrate))*10; //based off my generic formula coins_day=(seconds_day/(d*2^32/hashrate))*block_reward, where 2^32 is the average number of shares needed to find a block at a difficulty of 1 | ||
return ($timeperiod/($difficulty*2**32/$hashrate))*$blockreward; //based off my generic formula coins_day=(seconds_day/(d*2^32/hashrate))*block_reward, where 2^32 is the average number of shares needed to find a block at a difficulty of 1 | ||
} | ||
} | ||
|
||
function calculatePoWCoinsByNetworkHashPs($hashrate, $networkHashPs) { | ||
function calculatePoWCoinsByNetworkHashPs($hashrate, $networkHashPs, $blockreward, $blocktime, $timeperiod=86400) { | ||
if ($hashrate == 0) { | ||
return 0; | ||
} else { | ||
return ($hashrate/$networkHashPs)*((86400/120)*10); //based off my generic formula coins_day=(hashrate/nethash)*((seconds_day/block_time)*block_reward) | ||
return ($hashrate/$networkHashPs)*(($timeperiod/$blocktime)*$blockreward); //based off my generic formula coins_day=(hashrate/nethash)*((seconds_day/block_time)*block_reward | ||
} | ||
} | ||
|
||
function calculateMasternodeCoins($multiplier, $masternode_count) { | ||
return $multiplier * (((86400/120)*10)/$masternode_count); //based off my generic formula for one masternode coins_day = (((seconds_day/block_time)*block_rewards)/masternode_count) | ||
function calculateMasternodeCoins($multiplier, $masternode_count, $blockreward, $blocktime, $timeperiod=86400) { | ||
return $multiplier * ((($timeperiod/$blocktime)*$blockreward)/$masternode_count); //based off my generic formula for one masternode coins_day = (((seconds_day/block_time)*block_rewards)/masternode_count) | ||
} | ||
} | ||
?> | ||
?> |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
<?php | ||
class ticker | ||
class ticker //class to interact with CryptoBridge ticker API | ||
{ | ||
private $ticker = "https://api.crypto-bridge.org/api/v1/ticker"; | ||
private $tickerurl = "https://api.crypto-bridge.org/api/v1/ticker"; | ||
private $coins; | ||
|
||
function __construct() { | ||
$this->coins = json_decode(file_get_contents($this->tickerurl)); | ||
} | ||
|
||
function getGIN() { | ||
$arr = json_decode(file_get_contents($this->ticker)); | ||
|
||
for($i = 0; $i < count($arr); $i++) { | ||
if($arr[$i]->id == "GIN_BTC") { | ||
return $arr[$i]; | ||
for($i = 0; $i <= count($this->coins); $i++) { | ||
if($this->coins[$i]->id == "GIN_BTC") { | ||
return $this->coins[$i]; | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
?> | ||
?> |