mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-27 03:06:24 -05:00
feat(gui): Connect to preset rendezvous nodes at startup (#162)
This commit is contained in:
parent
7ebe59bc8d
commit
163f6fa94d
5 changed files with 37 additions and 19 deletions
|
|
@ -1,20 +1,25 @@
|
|||
import { ExtendedProviderStatus } from "models/apiModel";
|
||||
import { isProviderCompatible } from "./multiAddrUtils";
|
||||
import { isProviderCompatible, isProviderOutdated } from "./multiAddrUtils";
|
||||
|
||||
export function sortProviderList(list: ExtendedProviderStatus[]) {
|
||||
return list
|
||||
.filter(isProviderCompatible)
|
||||
.concat()
|
||||
.sort((firstEl, secondEl) => {
|
||||
// If neither of them have a relevancy score, sort by max swap amount
|
||||
if (firstEl.relevancy === undefined && secondEl.relevancy === undefined) {
|
||||
if (firstEl.maxSwapAmount > secondEl.maxSwapAmount) {
|
||||
return -1;
|
||||
}
|
||||
// If either provider is outdated, prioritize the one that isn't
|
||||
if (isProviderOutdated(firstEl) && !isProviderOutdated(secondEl)) return 1;
|
||||
if (!isProviderOutdated(firstEl) && isProviderOutdated(secondEl)) return -1;
|
||||
|
||||
// If neither of them have a relevancy score, sort by price
|
||||
if (firstEl.relevancy == null && secondEl.relevancy == null) {
|
||||
return firstEl.price - secondEl.price;
|
||||
}
|
||||
|
||||
// If only on of the two don't have a relevancy score, prioritize the one that does
|
||||
if (firstEl.relevancy === undefined) return 1;
|
||||
if (secondEl.relevancy === undefined) return -1;
|
||||
if (firstEl.relevancy == null) return 1;
|
||||
if (secondEl.relevancy == null) return -1;
|
||||
|
||||
// Otherwise, sort by relevancy score
|
||||
if (firstEl.relevancy > secondEl.relevancy) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue