HomePhabricator

[chronik-client] Added a mechanism for automatically selecting the fastest…

Description

[chronik-client] Added a mechanism for automatically selecting the fastest responding node, supporting two strategies: AsOrdered and ClosestFirst.

Summary:
This code implements an automatic node selection mechanism to avoid always using a single node.

A static method useStrategy is introduced in the ChronikClient class.

Users can enable automatic node selection by calling ChronikClient.useStrategy(ConnectionStrategy.ClosestFirst, urls).

This method will return a list of node URLs sorted by latency based on measureWebsocketLatency responses during instantiation.

Depends on D17935

Test Plan: npm test, Added some testing functions

Reviewers: Fabien, bytesofman, emack, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, bytesofman, O1 Bitcoin ABC, #bitcoin_abc

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17913

Details