doNostrRequestWithRelaySet method
Future<void>
doNostrRequestWithRelaySet(
- RequestState state, {
- bool splitRequestsByPubKeyMappings = true,
Implementation
Future<void> doNostrRequestWithRelaySet(RequestState state,
{bool splitRequestsByPubKeyMappings = true}) async {
if (state.unresolvedFilters.isEmpty || state.request.relaySet == null) {
return;
}
// TODO support more than 1 filter
RelaySet relaySet = state.request.relaySet!;
Filter filter = state.unresolvedFilters.first;
if (splitRequestsByPubKeyMappings) {
relaySet.splitIntoRequests(filter, state);
print(
"request for ${filter.authors != null ? filter.authors!.length : 0} authors with kinds: ${filter.kinds} made requests to ${state.requests.length} relays");
if (state.requests.isEmpty && relaySet.fallbackToBootstrapRelays) {
print(
"making fallback requests to ${_bootstrapRelays.length} bootstrap relays for ${filter.authors != null ? filter.authors!.length : 0} authors with kinds: ${filter.kinds}");
for (final url in _bootstrapRelays) {
state.addRequest(url, RelaySet.sliceFilterAuthors(filter));
}
}
} else {
for (final url in relaySet.urls) {
state.addRequest(url, RelaySet.sliceFilterAuthors(filter));
}
}
_globalState.inFlightRequests[state.id] = state;
for (MapEntry<String, RelayRequestState> entry in state.requests.entries) {
doRelayRequest(state.id, entry.value);
}
}