Browse Source

connection fixes and time adjustments

master
Kevin Froman 2 years ago
parent
commit
b7dc10a148
  1. 15
      js/hush-hush.js
  2. 1
      js/peer-lookup.js
  3. 2
      jspow/index.js

15
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)

1
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){

2
jspow/index.js

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

Loading…
Cancel
Save