getNip51RelaySets method
Future<List<Nip51Set> ?>
getNip51RelaySets(
- int kind,
- EventSigner signer, {
- bool forceRefresh = false,
return list of all nip51 relay sets that match a given kind
Implementation
Future<List<Nip51Set>?> getNip51RelaySets(int kind, EventSigner signer,
{bool forceRefresh = false}) async {
// Nip51Set? relaySet;// await getCachedNip51RelaySet(signer);
// if (relaySet == null || forceRefresh) {
Map<String, Nip51Set> newRelaySets = {};
await for (final event in _requests.query(filters: [
Filter(
authors: [signer.getPublicKey()],
kinds: [kind],
)
], cacheRead: !forceRefresh).stream) {
if (event.getDtag() != null) {
Nip51Set? newRelaySet = newRelaySets[event.getDtag()];
if (newRelaySet == null || newRelaySet.createdAt < event.createdAt) {
if (event.getDtag() != null) {
newRelaySet = await Nip51Set.fromEvent(event, signer);
}
if (newRelaySet != null) {
await _cacheManager.saveEvent(event);
newRelaySets[newRelaySet.name] = newRelaySet;
}
}
}
}
return newRelaySets.values.toList();
// }
// return [];
}