コード例 #1
0
ファイル: test.php プロジェクト: ionux/Bitcoin-phpMiner
 function testHash()
 {
     $data = array(603604794, -1992726684, 1050533917, -2049282207, 378026414, -38779290, -25761049, -551699343);
     $result = array(31505934, 205022762, -1518051379, -194223946, 2000539338, 1835853132, -99974255, 477201633);
     $this->assertEqual(Sha256::hash($data), $result);
 }
コード例 #2
0
ファイル: miner.php プロジェクト: ionux/Bitcoin-phpMiner
 function find($iterations = 0xffffffff)
 {
     $ret = null;
     while ($this->nonce < 0xffffffff && $iterations--) {
         $this->data[3] = $this->nonce;
         $h0 = Sha256::hash($this->midstate, $this->data);
         for ($j = 0; $j < 8; $j++) {
             $this->hash1[$j] = $h0[$j];
         }
         $h = Sha256::hash($this->hash1);
         if ($h[7] == 0) {
             foreach ($this->data as $d) {
                 $this->half[] = $d;
             }
             $ret = $this->half;
             break;
         }
         $this->nonce++;
         #if ($this->nonce % 100 == 0) {
         #	echo '|' . $this->nonce . '|';
         #	if ($this->nonce % 1000 === 0) echo '<br>';
         #	ob_flush();
         #	flush();
         #}
     }
     return $ret;
 }