connection fixes and time adjustments
This commit is contained in:
parent
fec805536a
commit
b7dc10a148
@ -101,6 +101,10 @@ function addMessage(message, timestamp){
|
|||||||
|
|
||||||
async function apiGET(path, queryString, raw=false){
|
async function apiGET(path, queryString, raw=false){
|
||||||
let nodeToUse = getCurrentNode()
|
let nodeToUse = getCurrentNode()
|
||||||
|
if (! nodeToUse){
|
||||||
|
console.debug("no node yet")
|
||||||
|
return
|
||||||
|
}
|
||||||
let requestTimeout = setTimeout(function(){
|
let requestTimeout = setTimeout(function(){
|
||||||
console.debug(nodeToUse + " timed out")
|
console.debug(nodeToUse + " timed out")
|
||||||
publicNodes = publicNodes.filter(item => item !== nodeToUse)
|
publicNodes = publicNodes.filter(item => item !== nodeToUse)
|
||||||
@ -123,13 +127,18 @@ async function apiGET(path, queryString, raw=false){
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function findMessages(){
|
async function findMessages(){
|
||||||
|
|
||||||
findMessageIntervalTime = 5000
|
findMessageIntervalTime = 5000
|
||||||
if (document.hidden){
|
if (document.hidden){
|
||||||
findMessageIntervalTime = 10000
|
findMessageIntervalTime = 10000
|
||||||
}
|
}
|
||||||
let messages = (await apiGET("getblocklist", "?type=" + postTopic + "&date=" + lastLookup)).split('\n')
|
try{
|
||||||
lastLookup = Math.floor((Date.now() / 1000))
|
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 => {
|
messages.forEach(block => {
|
||||||
if (!block) { return}
|
if (!block) { return}
|
||||||
block = reconstructHash(block)
|
block = reconstructHash(block)
|
||||||
|
@ -28,6 +28,7 @@ self.addEventListener('message', async function(e) {
|
|||||||
var data = JSON.parse(e.data)
|
var data = JSON.parse(e.data)
|
||||||
|
|
||||||
let peer = data['node']
|
let peer = data['node']
|
||||||
|
console.debug(peer)
|
||||||
let peerList = await lookupPeer(peer)
|
let peerList = await lookupPeer(peer)
|
||||||
peerList.forEach(node => {
|
peerList.forEach(node => {
|
||||||
if (node){
|
if (node){
|
||||||
|
@ -70,9 +70,11 @@ function doPow(metadata, data, difficulty){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
metadata['c'] += 1
|
metadata['c'] += 1
|
||||||
|
/*
|
||||||
if (metadata['c'] % 10000 == 0){
|
if (metadata['c'] % 10000 == 0){
|
||||||
console.debug(metadata['c'])
|
console.debug(metadata['c'])
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user