Skip to content

Commit

Permalink
Remove missing servers for internal servers list
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Jan 22, 2025
1 parent 4bac01a commit 5664b6e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- changed: Remove Blockbook servers from persisted internal servers list when updating this list from payload/default servers.

## 3.5.0 (2025-01-15)

- added: Implement `updateInfoPayload` for `EdgeCurrencyEngine` to get currency info updates from info-server.
Expand Down
12 changes: 11 additions & 1 deletion src/common/plugin/PluginState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export function makePluginState(settings: PluginStateSettings): PluginState {
},

async refreshServers(updatedCustomServers?: string[]): Promise<void> {
const serverList = getSelectedServerList()

let newServers: string[]
if (serverCache.enableCustomServers) {
newServers =
Expand All @@ -200,9 +202,17 @@ export function makePluginState(settings: PluginStateSettings): PluginState {
infoPayloadServers
: // Use the default servers from info file as final fallback
defaultSettings.blockbookServers

// Remove any server that's not included in the internal servers list.
// This is so we can control removal of poor servers from the
// info-server in real-time.
const missingServers = Object.keys(serverList).filter(
server => !newServers.includes(server)
)
serverScores.removeServers(serverList, missingServers)
}

serverScores.serverScoresLoad(getSelectedServerList(), newServers)
serverScores.serverScoresLoad(serverList, newServers)
await saveServerCache()

// Tell the engines about the new servers:
Expand Down
7 changes: 7 additions & 0 deletions src/common/plugin/ServerScores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,11 @@ export class ServerScores {

return selectedServers
}

removeServers(servers: ServerList, serverUrls: string[]): void {
for (const serverUrl of serverUrls) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete servers[serverUrl]
}
}
}

0 comments on commit 5664b6e

Please sign in to comment.