doRelayRequest method

bool doRelayRequest(
  1. String id,
  2. RelayRequestState request
)

Implementation

bool doRelayRequest(String id, RelayRequestState request) {
  if (_relayManager.isWebSocketOpen(request.url) &&
      (!_relayManager.blockedRelays.contains(request.url))) {
    try {
      List<dynamic> list = ["REQ", id];
      list.addAll(request.filters.map((filter) => filter.toMap()));
      Relay? relay = _relayManager.getRelay(request.url);
      if (relay != null) {
        relay.stats.activeRequests++;
        _relayManager.send(request.url, jsonEncode(list));
      }
      return true;
    } catch (e) {
      print(e);
    }
  } else {
    print(
        "COULD NOT SEND REQUEST TO ${request.url} since socket seems to be not open");

    _relayManager.reconnectRelay(request.url);
  }
  return false;
}