Ajout du dernier block par le haut

This commit is contained in:
2019-08-31 14:25:50 +02:00
parent 4301ad5cb5
commit 907e56d9cb
2 changed files with 43 additions and 10 deletions

View File

@@ -17,19 +17,26 @@ blockchainListener = function(){
function _isBlockNew(leblock)
{
return true;
return ((_last_block == null)||(_last_block.hash != leblock.hash));
};
function _getLastBlockInfo()
{
$.get( "data/getBlockInfo.php", function( data ) {
if (_isBlockNew(data))
{
_last_block = data;
_last_block_hooks.forEach(function(trigger) {
trigger(data);
});
}
if (_last_block_hooks.length > 0)
{
if (_isBlockNew(data))
{
_last_block = data;
_last_block_hooks.forEach(function(trigger) {
if (trigger instanceof Function)
trigger(data);
else
console.log(trigger);
});
}
}
}, "json" );
setTimeout(_getLastBlockInfo, 30000);