Ajout mode empty blocks
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
<?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';
|
||||||
|
|
||||||
|
function cmp_emptyblocks($a, $b)
|
||||||
|
{
|
||||||
|
if ($a[1] == $b[1]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($a[1] < $b[1]) ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$emptyblocks_list = [];
|
||||||
|
$filename=DATA_PATH."/emptybot/list.txt";
|
||||||
|
if (file_exists($filename))
|
||||||
|
{
|
||||||
|
$file = fopen(DATA_PATH."/emptybot/list.txt","r");
|
||||||
|
while(!feof($file))
|
||||||
|
{
|
||||||
|
$ligne=fgets($file);
|
||||||
|
$tableau=explode(' ', $ligne);
|
||||||
|
if ($tableau[1] != null)
|
||||||
|
$emptyblocks_list[] = [ $tableau[1], $tableau[2] ];
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($emptyblocks_list, "cmp_emptyblocks");
|
||||||
|
|
||||||
|
die(json_encode($emptyblocks_list));
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -98,6 +98,7 @@
|
|||||||
<br><select id="mode_selector" onchange="showInfos()">
|
<br><select id="mode_selector" onchange="showInfos()">
|
||||||
<option value=0>Full Blockchain Explorer</option>
|
<option value=0>Full Blockchain Explorer</option>
|
||||||
<option value=1>My special Blocks list</option>
|
<option value=1>My special Blocks list</option>
|
||||||
|
<option value=2>Empty Blocks list</option>
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<label>show block infos </label><input id="mode_checkbox" type="checkbox" onchange="toggleInfos()">
|
<label>show block infos </label><input id="mode_checkbox" type="checkbox" onchange="toggleInfos()">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ blockchainExplorer = function(){
|
|||||||
|
|
||||||
// Init array
|
// Init array
|
||||||
var _known_blocks = null;
|
var _known_blocks = null;
|
||||||
|
var _empty_blocks = null;
|
||||||
var _liste_blocks = [];
|
var _liste_blocks = [];
|
||||||
var _classes = ['bg-grey-even','bg-grey-odd'];
|
var _classes = ['bg-grey-even','bg-grey-odd'];
|
||||||
var _cur_class = 0;
|
var _cur_class = 0;
|
||||||
@@ -76,10 +77,13 @@ blockchainExplorer = function(){
|
|||||||
|
|
||||||
blockName = _getblockNameFromHash(block.hash);
|
blockName = _getblockNameFromHash(block.hash);
|
||||||
if (block.hash == _liste_blocks['TOP']) {
|
if (block.hash == _liste_blocks['TOP']) {
|
||||||
|
if (_mode != 2)
|
||||||
|
{
|
||||||
blockName = 'LAST BLOCK';
|
blockName = 'LAST BLOCK';
|
||||||
if (_mode == 1)
|
if (_mode == 1)
|
||||||
div_label = 'LAST';
|
div_label = 'LAST';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (blockName == '') blockName = 'block';
|
if (blockName == '') blockName = 'block';
|
||||||
else blockName = '<b>'+blockName+'</b>';
|
else blockName = '<b>'+blockName+'</b>';
|
||||||
|
|
||||||
@@ -105,6 +109,8 @@ blockchainExplorer = function(){
|
|||||||
|
|
||||||
$('#info_'+div_label).html(contenu);
|
$('#info_'+div_label).html(contenu);
|
||||||
|
|
||||||
|
if (_mode == 2) _cur_methode = 'emptybot';
|
||||||
|
|
||||||
downloadingImage.onload = function(){
|
downloadingImage.onload = function(){
|
||||||
var div0 = document.getElementById('img_'+div_label);
|
var div0 = document.getElementById('img_'+div_label);
|
||||||
div0.style.backgroundImage = "url(" + this.src + ")";
|
div0.style.backgroundImage = "url(" + this.src + ")";
|
||||||
@@ -263,6 +269,14 @@ blockchainExplorer = function(){
|
|||||||
}
|
}
|
||||||
//_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash;
|
//_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash;
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
// En mode "Blocks Vides", on prend le prochain de la liste
|
||||||
|
_liste_blocks['BOTTOM'] = _empty_blocks[0][0];
|
||||||
|
for(i = 0; i < _empty_blocks.length; i++){
|
||||||
|
if (data.height == _empty_blocks[i][1])
|
||||||
|
_liste_blocks['BOTTOM'] = _empty_blocks[i+1][0];
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.height > 0)
|
if (data.height > 0)
|
||||||
@@ -298,6 +312,9 @@ blockchainExplorer = function(){
|
|||||||
|
|
||||||
$('#blockchain').html('');
|
$('#blockchain').html('');
|
||||||
|
|
||||||
|
// Mode "Empty Blocks"
|
||||||
|
if (_mode == 2) block_hash_url += '?block_hash='+_empty_blocks[0][0];
|
||||||
|
else
|
||||||
if (block_name != 'LAST') block_hash_url += '?block_hash='+_getblocHashFromName(block_name);
|
if (block_name != 'LAST') block_hash_url += '?block_hash='+_getblocHashFromName(block_name);
|
||||||
|
|
||||||
$.getJSON(block_hash_url, function( data ) {
|
$.getJSON(block_hash_url, function( data ) {
|
||||||
@@ -352,6 +369,13 @@ blockchainExplorer = function(){
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (_empty_blocks == null)
|
||||||
|
{
|
||||||
|
$.getJSON('data/getEmptyBlocksList.php', function( data ) {
|
||||||
|
_empty_blocks = data;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _init(mode, infos)
|
function _init(mode, infos)
|
||||||
@@ -375,6 +399,13 @@ blockchainExplorer = function(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_empty_blocks == null)
|
||||||
|
{
|
||||||
|
$.getJSON('data/getEmptyBlocksList.php', function( data ) {
|
||||||
|
_empty_blocks = data;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
return _initBlockchain('LAST');
|
return _initBlockchain('LAST');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,6 +472,11 @@ blockchainExplorer = function(){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _initEmptyBlocks()
|
||||||
|
{
|
||||||
|
_init(2,false);
|
||||||
|
}
|
||||||
|
|
||||||
function _showBlockAllMethod(blockname)
|
function _showBlockAllMethod(blockname)
|
||||||
{
|
{
|
||||||
allMethod = [
|
allMethod = [
|
||||||
@@ -480,6 +516,8 @@ blockchainExplorer = function(){
|
|||||||
initOneBlock : _initOneBlock,
|
initOneBlock : _initOneBlock,
|
||||||
initBlockSelector : _initBlockSelector,
|
initBlockSelector : _initBlockSelector,
|
||||||
|
|
||||||
|
initEmptyBlocks : _initEmptyBlocks,
|
||||||
|
|
||||||
toggleInfos: _toggleInfos,
|
toggleInfos: _toggleInfos,
|
||||||
getLength: _getLength,
|
getLength: _getLength,
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
if ( window.scrollY > (2200+lastScroll))
|
if ( window.scrollY > (2200+lastScroll))
|
||||||
{
|
{
|
||||||
lastScroll = window.scrollY;
|
lastScroll = window.scrollY;
|
||||||
if ($('#blockSelector').val() == 'FULL')
|
if ($('#blockSelector').val() == 'EMPTY')
|
||||||
blockchainExplorer.addBottomBlock();
|
blockchainExplorer.addBottomBlock();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -66,7 +66,10 @@
|
|||||||
function selectBlock()
|
function selectBlock()
|
||||||
{
|
{
|
||||||
lastScroll = 0;
|
lastScroll = 0;
|
||||||
|
if ($('#blockSelector').val() != 'EMPTY')
|
||||||
blockchainExplorer.initOneBlock($('#blockSelector').val());
|
blockchainExplorer.initOneBlock($('#blockSelector').val());
|
||||||
|
else
|
||||||
|
blockchainExplorer.initEmptyBlocks();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -103,6 +106,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<select id="blockSelector" onchange="selectBlock()">
|
<select id="blockSelector" onchange="selectBlock()">
|
||||||
<option value='LAST'>LAST</option>
|
<option value='LAST'>LAST</option>
|
||||||
|
<option value='EMPTY'>EMPTY BLOCKS</option>
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<label>show block infos </label><input id="mode_checkbox" type="checkbox" onchange="toggleInfos()">
|
<label>show block infos </label><input id="mode_checkbox" type="checkbox" onchange="toggleInfos()">
|
||||||
|
|||||||
Reference in New Issue
Block a user