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 (#52)

* TRCL-2801 To avoid having a node with slow latency (thus +1 on height) being the preferred node

* bump version
  • Loading branch information
johnqh authored Oct 10, 2023
1 parent 8bde4f4 commit 16a2c9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions v4-client-js/__native__/__ios__/v4-native-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -196586,8 +196586,8 @@ 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 @@ -196618,15 +196618,15 @@ 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;
}
}
exports.NetworkOptimizer = NetworkOptimizer;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29ya19vcHRpbWl6ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbmV0d29ya19vcHRpbWl6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNkRBQXlEO0FBQ3pELGlFQUE2RDtBQUM3RCwyQ0FBMkM7QUFDM0MsbUNBQXlEO0FBRXpELE1BQU0sWUFBWTtJQUtkLFlBQ0UsTUFBYztRQUVkLElBQUksQ0FBQyxNQUFNLEd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thQUNELEdBQUcsQ0FBQyxDQUFDLE9BQU8sRUFBRSxFQUFFLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FDckQsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxnQkFBUSxDQUFDLENBQUM7UUFFcEIsSUFBSSxTQUFTLENBQUMsTUFBTSxLQUFLLENBQUMsRUFBRTtZQUMxQixNQUFNLElBQUksS0FBSyxDQUFDLGdDQUFnQyxDQUFDLENBQUM7U0FDbkQ7UUFDRCxNQUFNLFNBQVMsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLEdBQUcsU0FBUyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQUUsTUFBTSxFQUFFLEVBQUUsRUFBRSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDckUsT0FBTyxTQUFTO1lBQ2hCLHdEQUF3RDthQUNyRCxNQUFNLENBQUMsQ0FBQyxFQUFFLE1BQU0sRUFBRSxFQUFFLEVBQUUsQ0FBQyxNQUFNLEtBQUssU0FBUyxJQUFJLE1BQU0sS0FBSyxTQUFTLEdBQUcsQ0FBQyxDQUFDO1lBQzNFLHFEQUFxRDthQUNsRCxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxHQUFHLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7YUFDbEMsUUFBUSxDQUFDO0lBQ2QsQ0FBQztDQUNGO0FBN0ZELDRDQTZGQyJ9

/***/ }),

Expand Down
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.5",
"version": "0.38.6",
"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 16a2c9a

Please sign in to comment.