splitIntoRequests method
Implementation
void splitIntoRequests(Filter filter, RequestState groupRequest) {
for (var entry in relaysMap.entries) {
String url = entry.key;
List<PubkeyMapping> pubKeyMappings = entry.value;
if (pubKeyMappings.isEmpty) {
groupRequest.addRequest(url, [filter]);
} else if (filter.authors != null &&
filter.authors!.isNotEmpty &&
direction == RelayDirection.outbox) {
List<String> pubKeysForRelay = [];
for (String pubKey in filter.authors!) {
if (pubKeyMappings.any((pubKeyMapping) =>
pubKey == pubKeyMapping.pubKey ||
notCoveredPubkeys.any((element) => element.pubKey == pubKey))) {
pubKeysForRelay.add(pubKey);
}
}
if (pubKeysForRelay.isNotEmpty) {
groupRequest.addRequest(url,
sliceFilterAuthors(filter.cloneWithAuthors(pubKeysForRelay)));
}
} else if (filter.pTags != null &&
filter.pTags!.isNotEmpty &&
direction == RelayDirection.inbox) {
List<String> pubKeysForRelay = [];
for (String pubKey in filter.pTags!) {
if (pubKeyMappings.any((pubKeyMapping) =>
pubKey == pubKeyMapping.pubKey ||
notCoveredPubkeys.any((element) => element.pubKey == pubKey))) {
pubKeysForRelay.add(pubKey);
}
}
if (pubKeysForRelay.isNotEmpty) {
groupRequest.addRequest(
url, sliceFilterAuthors(filter.cloneWithPTags(pubKeysForRelay)));
}
} else if (filter.eTags != null && direction == RelayDirection.inbox) {
groupRequest.addRequest(url, [filter]);
} else {
/// TODO ????
}
}
}