Browse Source

missing spv random server pick cond

v0.25
pbca26 7 years ago
parent
commit
9be9e162c1
  1. 4
      routes/electrumjs/electrumServers.js
  2. 7
      routes/shepherd/auth.js
  3. 18
      routes/shepherd/electrum/coins.js

4
routes/electrumjs/electrumServers.js

@ -26,7 +26,7 @@ let electrumServers = {
'136.243.45.140:10002', '136.243.45.140:10002',
'18.216.195.109:10002', '18.216.195.109:10002',
'52.41.58.116:10002', '52.41.58.116:10002',
'52.67.48.29 :10002', '52.67.48.29:10002',
'13.124.87.194:10002', '13.124.87.194:10002',
'52.63.107.102:10002' '52.63.107.102:10002'
], ],
@ -64,7 +64,7 @@ let electrumServers = {
'136.243.45.140:10001', '136.243.45.140:10001',
'18.216.195.109:10001', '18.216.195.109:10001',
'52.41.58.116:10001', '52.41.58.116:10001',
'52.67.48.29 :10001', '52.67.48.29:10001',
'13.124.87.194:10001', '13.124.87.194:10001',
'52.63.107.102:10001' '52.63.107.102:10001'
], ],

7
routes/shepherd/auth.js

@ -8,7 +8,8 @@ module.exports = (shepherd) => {
let _status = false; let _status = false;
if (Object.keys(shepherd.coindInstanceRegistry).length) { if (Object.keys(shepherd.coindInstanceRegistry).length) {
if (Object.keys(shepherd.electrumCoins).length > 1 && shepherd.electrumCoins.auth) { if (Object.keys(shepherd.electrumCoins).length > 1 &&
shepherd.electrumCoins.auth) {
_status = true; _status = true;
} else if (Object.keys(shepherd.electrumCoins).length === 1 && !shepherd.electrumCoins.auth) { } else if (Object.keys(shepherd.electrumCoins).length === 1 && !shepherd.electrumCoins.auth) {
_status = true; _status = true;
@ -20,11 +21,7 @@ module.exports = (shepherd) => {
} }
successObj = { successObj = {
pubkey: 'nativeonly',
result: 'success',
handle: '',
status: _status ? 'unlocked' : 'locked', status: _status ? 'unlocked' : 'locked',
duration: 2507830,
}; };
res.end(JSON.stringify(successObj)); res.end(JSON.stringify(successObj));

18
routes/shepherd/electrum/coins.js

@ -16,7 +16,7 @@ module.exports = (shepherd) => {
return Math.floor(Math.random() * (max - min + 1)) + min; // the maximum is inclusive and the minimum is inclusive return Math.floor(Math.random() * (max - min + 1)) + min; // the maximum is inclusive and the minimum is inclusive
} }
let randomServer = {}; let randomServer;
// pick a random server to communicate with // pick a random server to communicate with
if (servers && if (servers &&
@ -26,8 +26,10 @@ module.exports = (shepherd) => {
const _serverDetails = _randomServer.split(':'); const _serverDetails = _randomServer.split(':');
if (_serverDetails.length === 2) { if (_serverDetails.length === 2) {
randomServer.ip = _serverDetails[0]; randomServer = {
randomServer.port = _serverDetails[1]; ip: _serverDetails[0],
port: _serverDetails[1],
};
} }
} }
@ -37,15 +39,21 @@ module.exports = (shepherd) => {
name: key, name: key,
abbr: coin, abbr: coin,
server: { server: {
ip: randomServer.ip, // shepherd.electrumServers[key].address, ip: randomServer ? randomServer.ip : shepherd.electrumServers[key].address,
port: randomServer.port, // shepherd.electrumServers[key].port, port: randomServer ? randomServer.port : shepherd.electrumServers[key].port,
}, },
serverList: shepherd.electrumServers[key].serverList ? shepherd.electrumServers[key].serverList : 'none', serverList: shepherd.electrumServers[key].serverList ? shepherd.electrumServers[key].serverList : 'none',
txfee: 'calculated' /*shepherd.electrumServers[key].txfee*/, txfee: 'calculated' /*shepherd.electrumServers[key].txfee*/,
}; };
shepherd.log(`default ${coin} electrum server ${shepherd.electrumServers[key].address + ':' + shepherd.electrumServers[key].port}`, true); shepherd.log(`default ${coin} electrum server ${shepherd.electrumServers[key].address + ':' + shepherd.electrumServers[key].port}`, true);
if (randomServer) {
shepherd.log(`random ${coin} electrum server ${randomServer.ip + ':' + randomServer.port}`, true); shepherd.log(`random ${coin} electrum server ${randomServer.ip + ':' + randomServer.port}`, true);
} else {
shepherd.log(`${coin} doesnt have any backup electrum servers`, true);
}
return true; return true;
} }
} }

Loading…
Cancel
Save