Bladeren bron

special_blocks is now an array of objects , and add getSpecialBlocksJSON

master
MEUNIER Thibaud 6 jaren geleden
bovenliggende
commit
43d87614ea
2 gewijzigde bestanden met toevoegingen van 143 en 22 verwijderingen
  1. +142
    -22
      blockchain/inc/block.php
  2. +1
    -0
      twitter/twitterbot/followers.json

+ 142
- 22
blockchain/inc/block.php Bestand weergeven

@ -1,5 +1,21 @@
<?php
class block
{
public $hash = null;
public $height = null;
public $name = null;
public $desc = null;
function __construct($ahash, $aheight, $aname = null, $adesc = null)
{
$this->hash = $ahash;
$this->height = $aheight;
$this->name = $aname;
$this->desc = $adesc;
}
}
class blockchain
{
private static $url_info = 'https://blockchain.info/fr';
@ -19,24 +35,119 @@ class blockchain
* 'SEGWIT_LOCK' - Block 479808 SEGWIT est verrouillé 09 08 2017
* 'SEGWIT' - Block 481823 SEGWIT est activé 24 08 2017
*/
private static $special_blocks = array (
'GENESIS' => '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
'THE_ANSWER' => '00000000314e90489514c787d615cea50003af2023796ccdd085b6bcc1fa28f5',
'LUCIFER' => '00000000fc5b3c76f27f810ee775e480ae7fd604fd196b2d8da4257fcd39f4f9',
'LEET' => '000000008bf44a528a09d203203a6a97c165cf53a92ecc27aed0b49b86a19564',
'TOPISTO' => '000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c',
'PIZZA' => '00000000006de085dadb3ec413ef074022fe781121b467e98960280dd246bb00',
'HALVING_1' => '000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e',
'WHALE201311' => '0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284',
'HALVING_2' => '000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1',
'BIP_91_LOCK' => '0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40',
'BCC' => '00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
'SEGWIT_LOCK' => '0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
'SEGWIT' => '000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
'BLOCK21E800' => '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a',
'WHALE201810' => '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d'
);
private static $special_blocks = null;
//
// Init special blocks array ...
//
public static function init()
{
self::$special_blocks = array ();
self::$special_blocks[] = new block(
'0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d',
545911,
'WHALE201810'
);
self::$special_blocks[] = new block(
'00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a',
528249,
'BLOCK21E800'
);
self::$special_blocks[] = new block(
'0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
506734,
'HURRICANE_1'
);
self::$special_blocks[] = new block(
'000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
481823,
'SEGWIT'
);
self::$special_blocks[] = new block(
'0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
479808,
'SEGWIT_LOCK'
);
self::$special_blocks[] = new block(
'00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
478559,
'BCC'
);
self::$special_blocks[] = new block(
'0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40',
477120,
'BIP_91_LOCK'
);
self::$special_blocks[] = new block(
'000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1',
420000,
'HALVING_2'
);
self::$special_blocks[] = new block(
'0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284',
270953,
'WHALE201311'
);
self::$special_blocks[] = new block(
'000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e',
210000,
'HALVING_1'
);
self::$special_blocks[] = new block(
'00000000006de085dadb3ec413ef074022fe781121b467e98960280dd246bb00',
57035,
'PIZZA'
);
self::$special_blocks[] = new block(
'000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c',
5637,
'TOPISTO'
);
self::$special_blocks[] = new block(
'000000008bf44a528a09d203203a6a97c165cf53a92ecc27aed0b49b86a19564',
1337,
'LEET'
);
self::$special_blocks[] = new block(
'00000000fc5b3c76f27f810ee775e480ae7fd604fd196b2d8da4257fcd39f4f9',
666,
'LUCIFER'
);
self::$special_blocks[] = new block(
'00000000314e90489514c787d615cea50003af2023796ccdd085b6bcc1fa28f5',
42,
'THE_ANSWER'
);
self::$special_blocks[] = new block(
'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
0,
'GENESIS'
);
}
// ---
// --- Retourne le JSON du tableau des blocs speciaux
// ---
public static function getSpecialBlocksJSON()
{
return json_encode(self::$special_blocks);
}
// ---
// --- Retourne le nom d'un block à partie de son hash
@ -44,8 +155,8 @@ class blockchain
// ---
public static function hash2SpecialName($block_hash)
{
foreach(self::$special_blocks as $key => $value)
if ($block_hash == $value) return $key;
foreach(self::$special_blocks as $value)
if ($block_hash == $value->hash) return $value->name;
return $block_hash;
}
@ -59,7 +170,14 @@ class blockchain
{
$block_hash = '';
if (isset(self::$special_blocks[$nom_du_block])) $block_hash = self::$special_blocks[$nom_du_block];
foreach(self::$special_blocks as $value)
{
if ($nom_du_block == $value->name)
{
$block_hash = $value->hash;
break;
}
}
if (file_exists(self::$offline_block)) $block_hash = 'offline';
@ -78,7 +196,7 @@ class blockchain
if (isset($myarray[0]))
{
usort( $myarray, function( $a, $b ) { return filemtime($b) - filemtime($a); } );
return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks['GENESIS']));
return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks[0]->hash));
}
// S'il n'y a rien dans le cache d'images
@ -443,4 +561,6 @@ class blockchain
}
}
blockchain::init();
?>

+ 1
- 0
twitter/twitterbot/followers.json Bestand weergeven

@ -0,0 +1 @@
["CryptoPressNews"]

Laden…
Annuleren
Opslaan