Ajout mode empty blocks

This commit is contained in:
2021-12-27 15:40:05 +01:00
parent b529a5e303
commit 130852ee98
4 changed files with 97 additions and 6 deletions
+42 -4
View File
@@ -2,6 +2,7 @@ blockchainExplorer = function(){
// Init array
var _known_blocks = null;
var _empty_blocks = null;
var _liste_blocks = [];
var _classes = ['bg-grey-even','bg-grey-odd'];
var _cur_class = 0;
@@ -76,9 +77,12 @@ blockchainExplorer = function(){
blockName = _getblockNameFromHash(block.hash);
if (block.hash == _liste_blocks['TOP']) {
blockName = 'LAST BLOCK';
if (_mode == 1)
div_label = 'LAST';
if (_mode != 2)
{
blockName = 'LAST BLOCK';
if (_mode == 1)
div_label = 'LAST';
}
}
if (blockName == '') blockName = 'block';
else blockName = '<b>'+blockName+'</b>';
@@ -105,6 +109,8 @@ blockchainExplorer = function(){
$('#info_'+div_label).html(contenu);
if (_mode == 2) _cur_methode = 'emptybot';
downloadingImage.onload = function(){
var div0 = document.getElementById('img_'+div_label);
div0.style.backgroundImage = "url(" + this.src + ")";
@@ -263,7 +269,15 @@ blockchainExplorer = function(){
}
//_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash;
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 (_liste_blocks['LENGTH'] % 15)
@@ -298,6 +312,9 @@ blockchainExplorer = function(){
$('#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);
$.getJSON(block_hash_url, function( data ) {
@@ -352,6 +369,13 @@ blockchainExplorer = function(){
return true;
});
}
if (_empty_blocks == null)
{
$.getJSON('data/getEmptyBlocksList.php', function( data ) {
_empty_blocks = data;
return true;
});
}
}
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');
}
@@ -441,6 +472,11 @@ blockchainExplorer = function(){
return true;
}
function _initEmptyBlocks()
{
_init(2,false);
}
function _showBlockAllMethod(blockname)
{
allMethod = [
@@ -480,6 +516,8 @@ blockchainExplorer = function(){
initOneBlock : _initOneBlock,
initBlockSelector : _initBlockSelector,
initEmptyBlocks : _initEmptyBlocks,
toggleInfos: _toggleInfos,
getLength: _getLength,