connection fixes and time adjustments

This commit is contained in:
Kevin Froman 2020-10-13 07:39:58 +00:00
parent fec805536a
commit b7dc10a148
3 changed files with 15 additions and 3 deletions

View File

@ -101,6 +101,10 @@ function addMessage(message, timestamp){
async function apiGET(path, queryString, raw=false){
let nodeToUse = getCurrentNode()
if (! nodeToUse){
console.debug("no node yet")
return
}
let requestTimeout = setTimeout(function(){
console.debug(nodeToUse + " timed out")
publicNodes = publicNodes.filter(item => item !== nodeToUse)
@ -123,13 +127,18 @@ async function apiGET(path, queryString, raw=false){
}
async function findMessages(){
findMessageIntervalTime = 5000
if (document.hidden){
findMessageIntervalTime = 10000
}
let messages = (await apiGET("getblocklist", "?type=" + postTopic + "&date=" + lastLookup)).split('\n')
lastLookup = Math.floor((Date.now() / 1000))
try{
var messages = (await apiGET("getblocklist", "?type=" + postTopic + "&date=" + lastLookup)).split('\n')
}
catch(e){
setTimeout(function(){findMessages()}, findMessageIntervalTime)
return
}
lastLookup = Math.floor((Date.now() / 1000)) - (findMessageIntervalTime / 1000) - 600
messages.forEach(block => {
if (!block) { return}
block = reconstructHash(block)

View File

@ -28,6 +28,7 @@ self.addEventListener('message', async function(e) {
var data = JSON.parse(e.data)
let peer = data['node']
console.debug(peer)
let peerList = await lookupPeer(peer)
peerList.forEach(node => {
if (node){

View File

@ -70,9 +70,11 @@ function doPow(metadata, data, difficulty){
}
}
metadata['c'] += 1
/*
if (metadata['c'] % 10000 == 0){
console.debug(metadata['c'])
}
*/
}
}