Add temporary timeout for blob peer list lookups
Returns an empty array for the peer list if the API call takes more than 6 seconds. If the lookup takes that long, there are almost never never any peers.
This commit is contained in:
parent
3c339492a0
commit
f3a501cf14
1 changed files with 13 additions and 1 deletions
14
js/lbry.js
14
js/lbry.js
|
@ -5,6 +5,7 @@ var lbry = {
|
||||||
rootPath: '.',
|
rootPath: '.',
|
||||||
daemonConnectionString: 'http://localhost:5279/lbryapi',
|
daemonConnectionString: 'http://localhost:5279/lbryapi',
|
||||||
webUiUri: 'http://localhost:5279',
|
webUiUri: 'http://localhost:5279',
|
||||||
|
peerListTimeout: 6000,
|
||||||
colors: {
|
colors: {
|
||||||
primary: '#155B4A'
|
primary: '#155B4A'
|
||||||
},
|
},
|
||||||
|
@ -190,7 +191,18 @@ lbry.getTotalCost = function(name, size, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getPeersForBlobHash = function(blobHash, callback) {
|
lbry.getPeersForBlobHash = function(blobHash, callback) {
|
||||||
lbry.call('peer_list', { blob_hash: blobHash }, callback);
|
let timedOut = false;
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
timedOut = true;
|
||||||
|
callback([]);
|
||||||
|
}, lbry.peerListTimeout);
|
||||||
|
|
||||||
|
lbry.call('peer_list', { blob_hash: blobHash }, function(peers) {
|
||||||
|
if (!timedOut) {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
callback(peers);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getCostInfoForName = function(name, callback) {
|
lbry.getCostInfoForName = function(name, callback) {
|
||||||
|
|
Loading…
Reference in a new issue