Compare commits
2 Commits
89215df21b
...
a4f572f962
| Author | SHA1 | Date | |
|---|---|---|---|
| a4f572f962 | |||
| 61930c1277 |
@@ -1,7 +1,7 @@
|
|||||||
<div class="container-fluid bg-grey">
|
<div class="container-fluid bg-grey">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<br><img id="logo_ARTICLE" src="images/block_image.php?methode=spline" width="100%; height: auto"></img>
|
<br><img id="logo_ARTICLE" src="images/block_image.php?methode=spline_2" width="100%; height: auto"></img>
|
||||||
<br><p>ARTICLE</p>
|
<br><p>ARTICLE</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|||||||
25
data/getKnownBlocksList.php
Normal file
25
data/getKnownBlocksList.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// ---
|
||||||
|
// --- La config globale
|
||||||
|
// ---
|
||||||
|
chdir('/opt/TOPISTO/apps');
|
||||||
|
require_once '/opt/TOPISTO/apps/global/inc/config.php';
|
||||||
|
|
||||||
|
// ---
|
||||||
|
// --- External dependances
|
||||||
|
// ---
|
||||||
|
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
|
||||||
|
|
||||||
|
// ---
|
||||||
|
// --- Internal dependances
|
||||||
|
// ---
|
||||||
|
require_once APP_PATH.'/blockchain/inc/block.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
echo blockchain::getSpecialBlocksJSON();
|
||||||
|
|
||||||
|
die();
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
var pos = $(this).offset().top;
|
var pos = $(this).offset().top;
|
||||||
var winTop = $(window).scrollTop();
|
var winTop = $(window).scrollTop();
|
||||||
if (pos < winTop + 600) {
|
if (pos < winTop + 600) {
|
||||||
ajouterPreviousBlock();
|
blockchainExplorer.ajouterPreviousBlock();
|
||||||
$(this).addClass("slide");
|
$(this).addClass("slide");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
{
|
{
|
||||||
cur_height = [];
|
cur_height = [];
|
||||||
cur_methode=la_methode;
|
cur_methode=la_methode;
|
||||||
return initBlockExplorer(null);
|
return blockchainExplorer.init();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,106 +0,0 @@
|
|||||||
<div class="container-fluid bg-grey">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h2>A digital currency</h2>
|
|
||||||
<p>
|
|
||||||
Use cryptography.<br>
|
|
||||||
No "central bank".<br>
|
|
||||||
P2P network.<br>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-4 align-middle">
|
|
||||||
<img src="images/bitcoin.jpg" width="100%; height: auto"></img>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-4 align-middle">
|
|
||||||
<img src="images/wallet.png" height="300px"></img>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h2>WALLET</h2>
|
|
||||||
<p>
|
|
||||||
Use cryptography.<br>
|
|
||||||
No "central bank".<br>
|
|
||||||
P2P network.<br>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container-fluid bg-grey">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h2>Transaction</h2>
|
|
||||||
<p>
|
|
||||||
When Bob is sending 42 <span class="glyphicon glyphicon-bitcoin"></span> to Alice, the bitcoin protocol is creating a transaction.<br>
|
|
||||||
A transaction is the balance between his Inputs and his Outputs.
|
|
||||||
<ul>
|
|
||||||
<li>First the network needs to be sure that Bob has got enough <span class="glyphicon glyphicon-bitcoin"></span> in his wallet.<br>So Bob will include a list of transactions that he has received before.<br>This is the inputs of the transactions.<br>For example, previous transaction's amount are 10, 25 and another 10, so total inputs are 45 <span class="glyphicon glyphicon-bitcoin"></span></li>
|
|
||||||
<li>As the input's sum is superior to the amount of the transaction, an ouput is added.<br>This output is the change to Bob.<br>In the example, this 3 <span class="glyphicon glyphicon-bitcoin"></span></li>
|
|
||||||
<li>Fees are took by the network to process the transaction.<br>Let say it will take 0.5<span class="glyphicon glyphicon-bitcoin"></span>.<br>This is another ouput</li>
|
|
||||||
<li>So Alice will get only a part of the transaction's amount.<br>this the last output, 41.5<span class="glyphicon glyphicon-bitcoin"></span></li>
|
|
||||||
</ul>
|
|
||||||
So the transaction is a made with :
|
|
||||||
<ul>
|
|
||||||
<li>Inputs : a list of previous transactions that bob has received</li>
|
|
||||||
<li>Outputs : a list of amounts to send to Alice, Bob, and fees</li>
|
|
||||||
<li>A timestamp</li>
|
|
||||||
</ul>
|
|
||||||
Then the wallet will broadcast the transaction on the network.<br>
|
|
||||||
It will be sent to the area called "mempool".<br>
|
|
||||||
Nodes of the network will validate the transaction by verfying the Inputs and the Ouputs.<br>
|
|
||||||
A hash of the transaction is computed.<br>
|
|
||||||
So the transaction is sealed.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-4 align-middle">
|
|
||||||
<img src="images/bob_to_alice.gif" width="100%; height: auto"></img>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-4">
|
|
||||||
<img src="images/tx2block.gif" width="100%; height: auto"></img>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h2>Block</h2>
|
|
||||||
<p>
|
|
||||||
Then the bitcoin protocol is grouping validated transactions in blocks.<br>
|
|
||||||
So a block is an array of transactions.<br>
|
|
||||||
A block is made with :
|
|
||||||
<ul>
|
|
||||||
<li>An array of transactions.<br>
|
|
||||||
That's what my script is drawing.<br>
|
|
||||||
Running the transactions array, it is computing the sum of each outputs of each transaction.<br>
|
|
||||||
Then, it draws a rectangle for each sum.<br>
|
|
||||||
</li>
|
|
||||||
<li>A "proof of work".<br>The miner is computing a special hash that depends on the array of transaction and that will answer to a constraint.<br>This hash is very difficult to compute. In fact it is not really computed, the miner must test every value until he find the solution.<br></li>
|
|
||||||
<li>That why the network will give him a reward.<br>This is a special transaction that has no inputs.</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container-fluid bg-grey">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h2>Blockchain</h2>
|
|
||||||
<p>
|
|
||||||
Each block has a hash and a reference to the ihash of the previous block.<br>
|
|
||||||
So blocks are chained together.<br>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-4">
|
|
||||||
<img src="/images/loading.gif" width="100%; height: auto"></img>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -26,20 +26,20 @@ $methode='hasard';
|
|||||||
$mode=9999;
|
$mode=9999;
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
// --- Le cas échéant, on cherche block passé en argument
|
// --- Le cas échéant, on cherche le block passé en argument
|
||||||
// ---
|
// ---
|
||||||
if (isset($_REQUEST['hash'])) $block_hash = $_REQUEST['hash'];
|
if (isset($_REQUEST['hash'])) $block_hash = $_REQUEST['hash'];
|
||||||
if (isset($_REQUEST['methode'])) $methode = $_REQUEST['methode'];
|
if (isset($_REQUEST['methode'])) $methode = $_REQUEST['methode'];
|
||||||
if (isset($_REQUEST['mode'])) $mode = intval($_REQUEST['mode']);
|
if (isset($_REQUEST['mode'])) $mode = intval($_REQUEST['mode']);
|
||||||
|
|
||||||
$img = null;
|
$img = null;
|
||||||
|
$str_mode = '';
|
||||||
|
if ($mode != 9999) $str_mode = '-'.$mode;
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
// --- Le cas général : on trouve le fichier image demandé
|
// --- Le cas général : on trouve le fichier image demandé
|
||||||
// ---
|
// ---
|
||||||
$imagefilename = DATA_PATH.'/'.$methode.'/'.$block_hash;
|
$imagefilename = DATA_PATH.'/'.$methode.'/'.$block_hash.$str_mode.'.png';
|
||||||
if ($mode != 9999) $imagefilename .= '-'.$mode;
|
|
||||||
$imagefilename .= '.png';
|
|
||||||
if (file_exists($imagefilename)) $img = imagecreatefrompng($imagefilename);
|
if (file_exists($imagefilename)) $img = imagecreatefrompng($imagefilename);
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|||||||
@@ -1,340 +1,267 @@
|
|||||||
// Init array
|
blockchainExplorer = function(){
|
||||||
var liste_blocks = [
|
|
||||||
{
|
|
||||||
name : 'WHALE201810',
|
|
||||||
hash : '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d',
|
|
||||||
height : 545911
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'BLOCK21E800',
|
|
||||||
hash : '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a',
|
|
||||||
height : 528249
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'HURRICANE_1',
|
|
||||||
hash : '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
|
|
||||||
height : 506734
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'SEGWIT',
|
|
||||||
hash : '000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
|
|
||||||
height : 481823
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'SEGWIT_LOCK',
|
|
||||||
hash : '0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
|
|
||||||
height : 479808
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'BCC',
|
|
||||||
hash : '00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
|
|
||||||
height : 478559
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'BIP_91_LOCK',
|
|
||||||
hash : '0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40',
|
|
||||||
height : 477120
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'HALVING_2',
|
|
||||||
hash : '000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1',
|
|
||||||
height : 420000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'WHALE201311',
|
|
||||||
hash : '0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284',
|
|
||||||
height : 270953
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'HALVING_1',
|
|
||||||
hash : '000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e',
|
|
||||||
height : 210000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'PIZZA',
|
|
||||||
hash : '00000000006de085dadb3ec413ef074022fe781121b467e98960280dd246bb00',
|
|
||||||
height : 57035
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'TOPISTO',
|
|
||||||
hash : '000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c',
|
|
||||||
height : 5637
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'LEET',
|
|
||||||
hash : '000000008bf44a528a09d203203a6a97c165cf53a92ecc27aed0b49b86a19564',
|
|
||||||
height : 1337
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'LUCIFER',
|
|
||||||
hash : '00000000fc5b3c76f27f810ee775e480ae7fd604fd196b2d8da4257fcd39f4f9',
|
|
||||||
height : 666
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'THE_ANSWER',
|
|
||||||
hash : '00000000314e90489514c787d615cea50003af2023796ccdd085b6bcc1fa28f5',
|
|
||||||
height : 42
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : 'GENESIS',
|
|
||||||
hash : '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
|
|
||||||
height : 0
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
var flag_nav = true;
|
// Init array
|
||||||
var classes = ['bg-grey-even','bg-grey-odd'];
|
var liste_blocks = null;
|
||||||
var cur_class = 0;
|
var flag_nav = true;
|
||||||
var cur_height = [];
|
var classes = ['bg-grey-even','bg-grey-odd'];
|
||||||
var cur_methode = 'hasard';
|
var cur_class = 0;
|
||||||
|
var cur_height = [];
|
||||||
|
var cur_methode = 'hasard';
|
||||||
|
var isInitSelector = false;
|
||||||
|
|
||||||
function precisionRound(number) {
|
function precisionRound(number) {
|
||||||
var precision = 4;
|
var precision = 4;
|
||||||
var factor = Math.pow(10, precision);
|
var factor = Math.pow(10, precision);
|
||||||
return Math.round((number/100000000) * factor) / factor;
|
return Math.round((number/100000000) * factor) / factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getblockNameFromHash(hash)
|
function getblockNameFromHash(hash)
|
||||||
|
{
|
||||||
|
var retour = '';
|
||||||
|
liste_blocks.forEach(function(item){
|
||||||
|
if (hash == item.hash) retour = item.name;
|
||||||
|
});
|
||||||
|
return retour;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getblocHashFromName(name)
|
||||||
|
{
|
||||||
|
var retour = '';
|
||||||
|
liste_blocks.forEach(function(item){
|
||||||
|
if (name == item.name) retour = item.hash;
|
||||||
|
});
|
||||||
|
return retour;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addInfoForBlock(block)
|
||||||
|
{
|
||||||
|
var height = '300px';
|
||||||
|
var contenu = '';
|
||||||
|
var downloadingImage = new Image();
|
||||||
|
|
||||||
|
cur_height.push(block.height);
|
||||||
|
|
||||||
|
cur_class = 1 - cur_class;
|
||||||
|
|
||||||
|
blockName = getblockNameFromHash(block.hash);
|
||||||
|
if (blockName != '') blockName = ' ( '+blockName+' )';
|
||||||
|
|
||||||
|
contenu += ' <h2> <span style="font-size:12px">block</span> '+block.height+blockName+'</h2>';
|
||||||
|
contenu += ' <table width="100%">';
|
||||||
|
//contenu += ' <tr><td>hash</td><td align="right"><b>'+block.hash+'</b></td></tr>';
|
||||||
|
//contenu += ' <tr><td>index</td><td align="right"><b>'+block.block_index+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>timestamp</td><td align="right"><b>'+block.time+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>nonce</td><td align="right"><b>'+block.nonce+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>nb tx</td><td align="right"><b>'+block.n_tx+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>outputs</td><td align="right"><b>'+precisionRound(block.topisto_outputs).toFixed(4)+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>inputs</td><td align="right"><b>'+precisionRound(block.topisto_inputs).toFixed(4)+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>fees</td><td align="right"><b>'+precisionRound(block.topisto_fees).toFixed(4)+'</b></td></tr>';
|
||||||
|
contenu += ' <tr><td>reward</td><td align="right"><b>'+precisionRound(block.topisto_reward).toFixed(4)+'</b></td></tr>';
|
||||||
|
contenu += ' </table>';
|
||||||
|
|
||||||
|
$('#info_'+block.height).html(contenu);
|
||||||
|
|
||||||
|
downloadingImage.onload = function(){
|
||||||
|
$('#img_'+block.height).attr('src', this.src);
|
||||||
|
//$('#img_'+block.height).attr('height', height);
|
||||||
|
//$('#img_'+block.height).attr('width','auto');
|
||||||
|
flag_nav = true;
|
||||||
|
};
|
||||||
|
downloadingImage.src = 'images/block_image.php?methode='+cur_methode+'&hash='+block.hash;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDivForBlock(block_height)
|
||||||
|
{
|
||||||
|
var contenu = '';
|
||||||
|
|
||||||
|
contenu += '<div id="block_'+block_height+'" class="container-fluid '+classes[cur_class]+'">';
|
||||||
|
contenu += ' <div class="row">';
|
||||||
|
contenu += ' <div class="col-sm-8" id="info_'+block_height+'">';
|
||||||
|
contenu += ' <h2>COMPUTING ...</h2>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += ' <div class="col-sm-4 text-right">';
|
||||||
|
contenu += ' <div width="100%" class="text-center">';
|
||||||
|
contenu += ' <img id="img_'+block_height+'" src="images/loading.gif" class="img-responsive"></img>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += '</div>';
|
||||||
|
|
||||||
|
$('#blockchain').append(contenu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDivForVoid()
|
||||||
|
{
|
||||||
|
var contenu = '';
|
||||||
|
|
||||||
|
contenu += '<div id="the_void" class="container-fluid '+classes[cur_class]+'">';
|
||||||
|
contenu += ' <div class="row">';
|
||||||
|
contenu += ' <div class="col-sm-8">';
|
||||||
|
contenu += ' <h2>the VOID ... </h2>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += ' <div class="col-sm-4 text-right">';
|
||||||
|
contenu += ' <div width="100%" class="text-center">';
|
||||||
|
contenu += ' <img src="images/loading.gif" class="img-responsive"></img>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += ' </div>';
|
||||||
|
contenu += '</div>';
|
||||||
|
|
||||||
|
$('#blockchain').append(contenu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleForwardBtn()
|
||||||
|
{
|
||||||
|
if (cur_height.length < 3)
|
||||||
{
|
{
|
||||||
var retour = '';
|
$('#fast_forward_btn').removeClass('btn-success');
|
||||||
liste_blocks.forEach(function(item){
|
$('#fast_forward_btn').addClass('btn-secondary');
|
||||||
if (hash == item.hash) retour = item.name;
|
$('#btn-forward').removeClass('btn-info');
|
||||||
});
|
$('#btn-forward').addClass('btn-secondary');
|
||||||
return retour;
|
} else {
|
||||||
|
$('#fast_forward_btn').removeClass('btn-secondary');
|
||||||
|
$('#fast_forward_btn').addClass('btn-success');
|
||||||
|
$('#btn-forward').removeClass('btn-secondary');
|
||||||
|
$('#btn-forward').addClass('btn-info');
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function getblocHashFromName(name)
|
function gotoBlock(block_name)
|
||||||
|
{
|
||||||
|
$(document).scrollTop( $("#explorer").offset().top );
|
||||||
|
// Bloquer la navigation pendant le calcul
|
||||||
|
if (!flag_nav)
|
||||||
{
|
{
|
||||||
var retour = '';
|
window.alert('A block image is currently computed, please wait ...');
|
||||||
liste_blocks.forEach(function(item){
|
return false;
|
||||||
if (name == item.name) retour = item.hash;
|
|
||||||
});
|
|
||||||
return retour;
|
|
||||||
}
|
}
|
||||||
|
flag_nav = false;
|
||||||
|
|
||||||
function addInfoForBlock(block)
|
if (block_name == 'NEXT')
|
||||||
{
|
{
|
||||||
var height = '300px';
|
flag_nav = true;
|
||||||
var contenu = '';
|
|
||||||
var downloadingImage = new Image();
|
|
||||||
|
|
||||||
cur_height.push(block.height);
|
// Supprimer un block
|
||||||
|
|
||||||
cur_class = 1 - cur_class;
|
|
||||||
|
|
||||||
blockName = getblockNameFromHash(block.hash);
|
|
||||||
if (blockName != '') blockName = ' ( '+blockName+' )';
|
|
||||||
|
|
||||||
contenu += ' <h2> <span style="font-size:12px">block</span> '+block.height+blockName+'</h2>';
|
|
||||||
contenu += ' <table width="100%">';
|
|
||||||
//contenu += ' <tr><td>hash</td><td align="right"><b>'+block.hash+'</b></td></tr>';
|
|
||||||
//contenu += ' <tr><td>index</td><td align="right"><b>'+block.block_index+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>timestamp</td><td align="right"><b>'+block.time+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>nonce</td><td align="right"><b>'+block.nonce+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>nb tx</td><td align="right"><b>'+block.n_tx+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>outputs</td><td align="right"><b>'+precisionRound(block.topisto_outputs).toFixed(4)+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>inputs</td><td align="right"><b>'+precisionRound(block.topisto_inputs).toFixed(4)+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>fees</td><td align="right"><b>'+precisionRound(block.topisto_fees).toFixed(4)+'</b></td></tr>';
|
|
||||||
contenu += ' <tr><td>reward</td><td align="right"><b>'+precisionRound(block.topisto_reward).toFixed(4)+'</b></td></tr>';
|
|
||||||
contenu += ' </table>';
|
|
||||||
|
|
||||||
$('#info_'+block.height).html(contenu);
|
|
||||||
|
|
||||||
downloadingImage.onload = function(){
|
|
||||||
$('#img_'+block.height).attr('src', this.src);
|
|
||||||
//$('#img_'+block.height).attr('height', height);
|
|
||||||
//$('#img_'+block.height).attr('width','auto');
|
|
||||||
flag_nav = true;
|
|
||||||
};
|
|
||||||
downloadingImage.src = 'images/block_image.php?methode='+cur_methode+'&hash='+block.hash;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addDivForBlock(block_height)
|
|
||||||
{
|
|
||||||
var contenu = '';
|
|
||||||
|
|
||||||
contenu += '<div id="block_'+block_height+'" class="container-fluid '+classes[cur_class]+'">';
|
|
||||||
contenu += ' <div class="row">';
|
|
||||||
contenu += ' <div class="col-sm-8" id="info_'+block_height+'">';
|
|
||||||
contenu += ' <h2>COMPUTING ...</h2>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += ' <div class="col-sm-4 text-right">';
|
|
||||||
contenu += ' <div width="100%" class="text-center">';
|
|
||||||
contenu += ' <img id="img_'+block_height+'" src="images/loading.gif" class="img-responsive"></img>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += '</div>';
|
|
||||||
|
|
||||||
$('#blockchain').append(contenu);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addDivForVoid()
|
|
||||||
{
|
|
||||||
var contenu = '';
|
|
||||||
|
|
||||||
contenu += '<div id="the_void" class="container-fluid '+classes[cur_class]+'">';
|
|
||||||
contenu += ' <div class="row">';
|
|
||||||
contenu += ' <div class="col-sm-8">';
|
|
||||||
contenu += ' <h2>the VOID ... </h2>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += ' <div class="col-sm-4 text-right">';
|
|
||||||
contenu += ' <div width="100%" class="text-center">';
|
|
||||||
contenu += ' <img src="images/loading.gif" class="img-responsive"></img>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += ' </div>';
|
|
||||||
contenu += '</div>';
|
|
||||||
|
|
||||||
$('#blockchain').append(contenu);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleForwardBtn()
|
|
||||||
{
|
|
||||||
if (cur_height.length < 3)
|
if (cur_height.length < 3)
|
||||||
{
|
{
|
||||||
$('#fast_forward_btn').removeClass('btn-success');
|
window.alert('No Next Block, you are at '+$('#blockSelector').val()+' block !');
|
||||||
$('#fast_forward_btn').addClass('btn-secondary');
|
|
||||||
$('#btn-forward').removeClass('btn-info');
|
|
||||||
$('#btn-forward').addClass('btn-secondary');
|
|
||||||
} else {
|
|
||||||
$('#fast_forward_btn').removeClass('btn-secondary');
|
|
||||||
$('#fast_forward_btn').addClass('btn-success');
|
|
||||||
$('#btn-forward').removeClass('btn-secondary');
|
|
||||||
$('#btn-forward').addClass('btn-info');
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function gotoBlock(block_name)
|
|
||||||
{
|
|
||||||
$(document).scrollTop( $("#explorer").offset().top );
|
|
||||||
|
|
||||||
// Bloquer la navigation pendant le calcul
|
|
||||||
if (!flag_nav)
|
|
||||||
{
|
|
||||||
window.alert('A block image is currently computed, please wait ...');
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flag_nav = false;
|
|
||||||
|
|
||||||
if (block_name == 'NEXT')
|
liste_blocks['PREVIOUS'] = liste_blocks['BLOCK_'+cur_height[cur_height.length-1]];
|
||||||
{
|
cur_height.pop();
|
||||||
flag_nav = true;
|
|
||||||
|
|
||||||
// Supprimer un block
|
toggleForwardBtn();
|
||||||
if (cur_height.length < 3)
|
|
||||||
{
|
|
||||||
window.alert('No Next Block, you are at '+$('#blockSelector').val()+' block !');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
liste_blocks['PREVIOUS'] = liste_blocks['BLOCK_'+cur_height[cur_height.length-1]];
|
$('#block_'+cur_height[cur_height.length-2]).slideDown(400, function() {
|
||||||
cur_height.pop();
|
// Animation complete.
|
||||||
|
$('#blockchain').children('div:last').remove();
|
||||||
|
cur_class = 1 - cur_class;
|
||||||
|
});
|
||||||
|
|
||||||
toggleForwardBtn();
|
} else {
|
||||||
|
// Ajouter un block
|
||||||
$('#block_'+cur_height[cur_height.length-2]).slideDown(400, function() {
|
|
||||||
// Animation complete.
|
|
||||||
$('#blockchain').children('div:last').remove();
|
|
||||||
cur_class = 1 - cur_class;
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Ajouter un block
|
|
||||||
addDivForBlock(cur_height[cur_height.length-1] - 1);
|
|
||||||
|
|
||||||
// Décaler d'un block vers le haut
|
|
||||||
if (cur_height.length > 1) $('#block_'+cur_height[cur_height.length-2]).slideUp();
|
|
||||||
|
|
||||||
block_hash = '';
|
|
||||||
if (block_name != 'LAST') block_hash = '?block_hash='+liste_blocks[block_name];
|
|
||||||
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
|
||||||
liste_blocks['PREVIOUS'] = data.prev;
|
|
||||||
liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
||||||
addInfoForBlock(data);
|
|
||||||
|
|
||||||
toggleForwardBtn();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ajouterPreviousBlock()
|
|
||||||
{
|
|
||||||
// Bloquer la navigation pendant le calcul
|
|
||||||
if (!flag_nav) return false;
|
|
||||||
flag_nav = false;
|
|
||||||
|
|
||||||
// Ajouter un div
|
|
||||||
addDivForBlock(cur_height[cur_height.length-1] - 1);
|
addDivForBlock(cur_height[cur_height.length-1] - 1);
|
||||||
// Mettre les infos du
|
|
||||||
block_hash = '?block_hash='+liste_blocks['PREVIOUS'];
|
// Décaler d'un block vers le haut
|
||||||
|
if (cur_height.length > 1) $('#block_'+cur_height[cur_height.length-2]).slideUp();
|
||||||
|
|
||||||
|
block_hash = '';
|
||||||
|
if (block_name != 'LAST') block_hash = '?block_hash='+liste_blocks[block_name];
|
||||||
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
||||||
liste_blocks['PREVIOUS'] = data.prev;
|
liste_blocks['PREVIOUS'] = data.prev;
|
||||||
liste_blocks['BLOCK_'+data.height] = data.hash;
|
liste_blocks['BLOCK_'+data.height] = data.hash;
|
||||||
addInfoForBlock(data);
|
addInfoForBlock(data);
|
||||||
|
|
||||||
|
toggleForwardBtn();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initBlockchain(block_name)
|
return true;
|
||||||
{
|
}
|
||||||
$(document).scrollTop( $("#explorer").offset().top );
|
|
||||||
|
|
||||||
$('#blockchain').html('');
|
function _ajouterPreviousBlock()
|
||||||
cur_height = [];
|
{
|
||||||
cur_class = 0;
|
// Bloquer la navigation pendant le calcul
|
||||||
flag_nav = true;
|
if (!flag_nav) return false;
|
||||||
|
flag_nav = false;
|
||||||
|
|
||||||
block_hash = '';
|
// Ajouter un div
|
||||||
if (block_name != 'LAST') block_hash = '?block_hash='+getblocHashFromName(block_name);
|
addDivForBlock(cur_height[cur_height.length-1] - 1);
|
||||||
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
// Mettre les infos du
|
||||||
addDivForBlock(data.height);
|
block_hash = '?block_hash='+liste_blocks['PREVIOUS'];
|
||||||
addInfoForBlock(data);
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
||||||
|
liste_blocks['PREVIOUS'] = data.prev;
|
||||||
|
liste_blocks['BLOCK_'+data.height] = data.hash;
|
||||||
|
addInfoForBlock(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
liste_blocks['PREVIOUS'] = data.prev;
|
function initBlockchain(block_name)
|
||||||
if (data.prev != '0000000000000000000000000000000000000000000000000000000000000000')
|
{
|
||||||
gotoBlock('PREVIOUS');
|
$(document).scrollTop( $("#explorer").offset().top );
|
||||||
else
|
$('#blockchain').html('');
|
||||||
addDivForVoid();
|
cur_height = [];
|
||||||
});
|
cur_class = 0;
|
||||||
|
flag_nav = true;
|
||||||
|
|
||||||
return true;
|
block_hash = '';
|
||||||
}
|
if (block_name != 'LAST') block_hash = '?block_hash='+getblocHashFromName(block_name);
|
||||||
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
||||||
|
addDivForBlock(data.height);
|
||||||
|
addInfoForBlock(data);
|
||||||
|
|
||||||
function blockSelectorChange()
|
liste_blocks['PREVIOUS'] = data.prev;
|
||||||
{
|
if (data.prev != '0000000000000000000000000000000000000000000000000000000000000000')
|
||||||
initBlockchain($('#blockSelector').val());
|
gotoBlock('PREVIOUS');
|
||||||
$('#fast_forward_btn').attr('data-original-title', $('#blockSelector').val());
|
else
|
||||||
}
|
addDivForVoid();
|
||||||
function initBlockSelector()
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function blockSelectorChange()
|
||||||
|
{
|
||||||
|
initBlockchain($('#blockSelector').val());
|
||||||
|
$('#fast_forward_btn').attr('data-original-title', $('#blockSelector').val());
|
||||||
|
}
|
||||||
|
|
||||||
|
function initBlockSelector()
|
||||||
|
{
|
||||||
|
if (!isInitSelector)
|
||||||
{
|
{
|
||||||
// Init the selector
|
// Init the selector
|
||||||
var select = $('#blockSelector');
|
var select = $('#blockSelector');
|
||||||
if (typeof select.isInitSelector == 'undefined')
|
|
||||||
{
|
|
||||||
select.isInitSelector = true;
|
|
||||||
$.each(liste_blocks, function (key, bloc) {
|
|
||||||
select.append(new Option(bloc.name, bloc.name));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initBlockExplorer(leblock)
|
$.each(liste_blocks, function (key, bloc) {
|
||||||
{
|
select.append(new Option(bloc.name, bloc.name));
|
||||||
|
});
|
||||||
|
|
||||||
|
isInitSelector = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _init()
|
||||||
|
{
|
||||||
|
$.getJSON('data/getKnownBlocksList.php', function( data ) {
|
||||||
|
liste_blocks = data;
|
||||||
initBlockSelector();
|
initBlockSelector();
|
||||||
if (cur_height.length == 0) initBlockchain('LAST');
|
if (cur_height.length == 0) initBlockchain('LAST');
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
blockchainListener.addBlockHook(initBlockExplorer);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {init: _init, ajouterPreviousBlock: _ajouterPreviousBlock};
|
||||||
|
}();
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
blockchainExplorer.init();
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user