diff --git a/js/hush-hush.js b/js/hush-hush.js index afef0d3..e6cdad6 100644 --- a/js/hush-hush.js +++ b/js/hush-hush.js @@ -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) diff --git a/js/peer-lookup.js b/js/peer-lookup.js index 17c739e..3beba24 100644 --- a/js/peer-lookup.js +++ b/js/peer-lookup.js @@ -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){ diff --git a/jspow/index.js b/jspow/index.js index b7512d6..23e0d12 100644 --- a/jspow/index.js +++ b/jspow/index.js @@ -70,9 +70,11 @@ function doPow(metadata, data, difficulty){ } } metadata['c'] += 1 + /* if (metadata['c'] % 10000 == 0){ console.debug(metadata['c']) } + */ } }