query method

NdkResponse query({
  1. required List<Filter> filters,
  2. String name = '',
  3. RelaySet? relaySet,
  4. bool cacheRead = true,
  5. bool cacheWrite = true,
  6. Duration? timeout,
  7. dynamic timeoutCallbackUserFacing()?,
  8. dynamic timeoutCallback()?,
  9. Iterable<String>? explicitRelays,
  10. int? desiredCoverage,
})

Performs a low-level Nostr query

filters A list of filters to apply to the query
name An optional name used as an ID prefix
relaySet An optional set of relays to query
cacheRead Whether to read from cache
cacheWrite Whether to write results to cache
timeout An optional timeout in seconds for the query if not set ndk default will be used
explicitRelays A list of specific relays to use, bypassing inbox/outbox
desiredCoverage The number of relays per pubkey to query, default: 2
timeoutCallbackUserFacing A user facing timeout callback, this callback should be given to the lib user
timeoutCallback An internal timeout callback, this callback should be used for internal error handling \

Returns an NdkResponse containing the query result stream, future

Implementation

NdkResponse query({
  required List<Filter> filters,
  String name = '',
  RelaySet? relaySet,
  bool cacheRead = true,
  bool cacheWrite = true,
  Duration? timeout,
  Function()? timeoutCallbackUserFacing,
  Function()? timeoutCallback,
  Iterable<String>? explicitRelays,
  int? desiredCoverage,
}) {
  timeout ??= _defaultQueryTimeout;

  return requestNostrEvent(NdkRequest.query(
    '$name-${Helpers.getRandomString(10)}',
    name: name,
    filters: filters.map((e) => e.clone()).toList(),
    relaySet: relaySet,
    cacheRead: cacheRead,
    cacheWrite: cacheWrite,
    timeoutDuration: timeout,
    timeoutCallbackUserFacing: timeoutCallbackUserFacing,
    timeoutCallback: timeoutCallback,
    explicitRelays: explicitRelays,
    desiredCoverage:
        desiredCoverage ?? RequestDefaults.DEFAULT_BEST_RELAYS_MIN_COUNT,
  ));
}