Skip to content

Commit

Permalink
TRCL-2801 To avoid having a node with slow latency (thus +1 on height…
Browse files Browse the repository at this point in the history
…) being the preferred node
  • Loading branch information
johnqh committed Oct 9, 2023
1 parent 6cf0ded commit 45cfdd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion v4-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dydxprotocol/v4-client-js",
"version": "0.38.4",
"version": "0.38.5",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions v4-client-js/src/network_optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class NetworkOptimizer {
}
const maxHeight = Math.max(...responses.map(({ height }) => height));
return responses
// Only consider nodes at `maxHeight`
.filter(({ height }) => height === maxHeight)
// Only consider nodes at `maxHeight` or `maxHeight - 1`
.filter(({ height }) => height === maxHeight || height === maxHeight - 1)
// Return the endpoint with the fastest response time
.sort((a, b) => a.time - b.time)[0]
.endpoint;
Expand Down Expand Up @@ -105,8 +105,8 @@ export class NetworkOptimizer {
}
const maxHeight = Math.max(...responses.map(({ height }) => height));
return responses
// Only consider nodes at `maxHeight`
.filter(({ height }) => height === maxHeight)
// Only consider nodes at `maxHeight` or `maxHeight - 1`
.filter(({ height }) => height === maxHeight || height === maxHeight - 1)
// Return the endpoint with the fastest response time
.sort((a, b) => a.time - b.time)[0]
.endpoint;
Expand Down

0 comments on commit 45cfdd3

Please sign in to comment.