*If max relays is greater than 0, and we have more relays than max relays, pick a random selection
This commit is contained in:
parent
fa8910a4fd
commit
47356ed6e0
|
@ -86,6 +86,22 @@ export default class WisdomRpcQuery extends RpcQueryBase {
|
|||
}
|
||||
|
||||
protected getRelays(): string[] | [] {
|
||||
return this._network.relays;
|
||||
if (
|
||||
this._network.maxRelays === 0 ||
|
||||
this._network.relays.length <= this._network.maxRelays
|
||||
) {
|
||||
return this._network.relays;
|
||||
}
|
||||
|
||||
const list: string[] = [];
|
||||
let available = this._network.relays;
|
||||
|
||||
while (list.length < this._network.maxRelays) {
|
||||
const item = Math.floor(Math.random() * available.length);
|
||||
list.push(available[item]);
|
||||
available.splice(item, 1);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue