|
|
@ -1,3 +1,13 @@ |
|
|
|
var chainActivationLastUpdate, |
|
|
|
chainActivationLastUpdateTimeout = 1; |
|
|
|
|
|
|
|
function checkTimestamp(dateToCheck) { |
|
|
|
var currentEpochTime = new Date(Date.now()) / 1000, |
|
|
|
secondsElapsed = Number(currentEpochTime) - Number(dateToCheck / 1000); |
|
|
|
|
|
|
|
return Math.floor(secondsElapsed); |
|
|
|
} |
|
|
|
|
|
|
|
function RunKMDInitFunctions() { |
|
|
|
NProgress.done(true); |
|
|
|
NProgress.configure({ |
|
|
@ -87,38 +97,40 @@ function RunKMDInitFunctions() { |
|
|
|
var currentBestBlockInterval; |
|
|
|
function startBestBlockInterval() { |
|
|
|
currentBestBlockInterval = setInterval(function() { |
|
|
|
$.ajax({ |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
'herdname': 'komodo', |
|
|
|
'lastLines': 1 |
|
|
|
}, |
|
|
|
url: 'http://127.0.0.1:17777/shepherd/debuglog', |
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
if (data.indexOf('UpdateTip') > -1) { |
|
|
|
var temp = data.split(' '); |
|
|
|
|
|
|
|
for (var i = 0; i < temp.length; i++) { |
|
|
|
if (temp[i].indexOf('height=') > -1) { |
|
|
|
var currentBestChain = temp[i].replace('height=', ''); |
|
|
|
$('#activating-komodod-tridot').hide(); |
|
|
|
$('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')'); |
|
|
|
|
|
|
|
if (currentBestChain === totalBlocksInExplorer) { |
|
|
|
//clearInterval(totalBlocksInExplorerInterval);
|
|
|
|
clearInterval(currentBestBlockInterval); |
|
|
|
if (!chainActivationLastUpdate || checkTimestamp(chainActivationLastUpdate) > chainActivationLastUpdateTimeout) { |
|
|
|
$.ajax({ |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
'herdname': 'komodo', |
|
|
|
'lastLines': 1 |
|
|
|
}, |
|
|
|
url: 'http://127.0.0.1:17777/shepherd/debuglog', |
|
|
|
success: function(data, textStatus, jqXHR) { |
|
|
|
if (data.indexOf('UpdateTip') > -1) { |
|
|
|
var temp = data.split(' '); |
|
|
|
|
|
|
|
for (var i = 0; i < temp.length; i++) { |
|
|
|
if (temp[i].indexOf('height=') > -1) { |
|
|
|
var currentBestChain = temp[i].replace('height=', ''); |
|
|
|
$('#activating-komodod-tridot').hide(); |
|
|
|
$('#activating-komodod-progress').html(': ' + Math.floor(currentBestChain * 100 / totalBlocksInExplorer) + '% (blocks ' + currentBestChain + ' / ' + totalBlocksInExplorer + ')'); |
|
|
|
chainActivationLastUpdate = Date.now(); |
|
|
|
if (currentBestChain === totalBlocksInExplorer) { |
|
|
|
//clearInterval(totalBlocksInExplorerInterval);
|
|
|
|
clearInterval(currentBestBlockInterval); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, textStatus, error) { |
|
|
|
console.log('failed getting debug.log'); |
|
|
|
console.log(xhr.statusText); |
|
|
|
console.log(textStatus); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, textStatus, error) { |
|
|
|
console.log('failed getting debug.log'); |
|
|
|
console.log(xhr.statusText); |
|
|
|
console.log(textStatus); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, 2000); |
|
|
|
} |
|
|
|
|
|
|
|