Added timeout to upload
This commit is contained in:
parent
9c352e1917
commit
94045057c3
@ -39,17 +39,34 @@ document.getElementById("createMessageBtn").onclick = async function(){
|
|||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
powWorker.addEventListener('message', function(e) {
|
async function doUpload(data){
|
||||||
let decoder = new TextDecoder("utf-8")
|
if (! publicNodes.length){
|
||||||
let message = decoder.decode(e.data)
|
setTimeout(function(){
|
||||||
|
doUpload(data)
|
||||||
|
}, 1000)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fetch('http://' + getCurrentNode() + '.onion/upload', {
|
let decoder = new TextDecoder("utf-8")
|
||||||
|
let uploadTimeout = setTimeout(function(){
|
||||||
|
console.debug("upload timed out")
|
||||||
|
doUpload(data)
|
||||||
|
}, 30000)
|
||||||
|
let upload = await fetch('http://' + getCurrentNode() + '.onion/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/octet-stream"
|
"content-type": "application/octet-stream"
|
||||||
},
|
},
|
||||||
body: decoder.decode(e.data)
|
body: decoder.decode(data)
|
||||||
})
|
})
|
||||||
|
clearTimeout(uploadTimeout)
|
||||||
|
if (upload.ok){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
doUpload(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
powWorker.addEventListener('message', function(e) {
|
||||||
console.debug("Generated block: " + doHashHex(e.data))
|
console.debug("Generated block: " + doHashHex(e.data))
|
||||||
|
doUpload(e.data)
|
||||||
}, false)
|
}, false)
|
||||||
|
Loading…
Reference in New Issue
Block a user