getActiveConnection method

Future<UrlConnection?> getActiveConnection()

Fetches the currently active XMR connection from the server.

This method sends a GetConnectionRequest to retrieve the currently active XMR node connection.

Example:

final activeConnection = await xmrConnectionsClient.getActiveConnection();
print('Active Node: ${activeConnection?.url}');

Returns:

  • A Future containing the active UrlConnection.
  • null if an error occurs.

Implementation

Future<UrlConnection?> getActiveConnection() async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {
    final response = await havenoChannel.xmrConnectionsClient!
        .getConnection(GetConnectionRequest());
    return response.connection;
  } on GrpcError catch (e) {
    handleGrpcError(e);
    return null;
  }
}