getSubscribers method
getSubscribers RPC returns the number of subscribers of a topic
(not including txPool). If subscriberHashPrefix
is not empty, only subscriber
whose sha256(pubkey+identifier) contains this prefix will be counted. Each
prefix byte will reduce result count to about 1/256, and also reduce response
time to about 1/256 if there are a lot of subscribers. This is a good way to
sample subscribers randomly with low cost.
Implementation
Future<Map<String, dynamic>?> getSubscribers({
required String topic,
int offset = 0,
int limit = 10000,
bool meta = true,
bool txPool = true,
Uint8List? subscriberHashPrefix,
}) async {
try {
Map? resp = await _methodChannel.invokeMethod('getSubscribers', {
'_id': this.address,
'topic': topic,
'offset': offset,
'limit': limit,
'meta': meta,
'txPool': txPool,
'subscriberHashPrefix': subscriberHashPrefix,
});
if (resp == null) {
return null;
}
return Map<String, dynamic>.from(resp);
} catch (e) {
rethrow;
}
}