Constructs an instance of the network service and connects
to the configured defaultNode
(config/network.json). Note
that connection handling is currently automatic and executed
upon instanciation of network service objects.
The blocks repository that permits to execute REST
requests on the /blocks
namespace.
The chain repository that permits to execute REST
requests on the /chain
namespace.
The information related to the connected network. This is necessary to connect to other nodes of the network.
The currently connected node.
This class' HTTP service. It's a handler for HTTP requests and contains
methods for executing remote API calls, e.g. calling a GET
HTTP API
endpoint.
The node repository that permits to execute REST
requests on the /node
namespace.
The repository factory used to communicate with the connected node's REST interface.
The transaction repository that permits to execute REST
requests on the /transaction
namespace.
Helper method that connects to a node's REST interface
using the SDK's RepositoryFactoryHttp
class. Note that
the connection payload is pre-configured so that extra
requests are spared.
This method forwards the execution of promises using
Promise.all()
and given request failure, connects to
a different node that is currently in a healthy state.
Note that this method debounces the API calls such that
requests to a node are done at a maximum pace of 3 requests
in a second.
An array of promises that will be executed.
An array of results as promised.
This helper method forwards the execution of a promise
to call the endpoint /chain/info
on a node.
Public helper method to retrieve the network parameters from the
runtime configuration. This is helpful to create new adapters that
connect to nodes on dHealth Network.
This method is used internally to populate the currentNetwork
class property and can be used whenever network parameters must be
fetched from the runtime configuration.
Public helper method to retrieve the network currenciy from the
runtime configuration. This is helpful to create new adapters that
connect to nodes on dHealth Network and to avoid extra requests
to the node.
This method is used internally to populate the networkCurrencies
field in the currentNetwork class property and can be used
whenever network currencies information is necessary.
Helper method to pick a healthy and available node
from the runtime configuration. If none of the configured
nodes is currently in a healthy state, this method will
use the http://peers.dhealth.cloud:7903/network/nodes endpoint
instead.
Note that this method executes a call to the node's API
using the endpoint /node/health
to determine the health
state of selected nodes. As of now, the nodes that are
added to the runtime configuration will be iterated in a
sequential and ascending order.
Helper method that constructs a node URL using the NodeConnectionPayload payload.
Generated using TypeDoc
This class serves as a connection handler for nodes on dHealth Network. It uses a node's REST interface to fetch data directly from the node.
Note that the connection is done upon instanciation. A possible refactor of this class may move this process such that the connection adapter is not always considered "connected", as is currently the case.
v0.1.0