getServiceStatistics method

Map<String, int> getServiceStatistics()

Get count of addresses by service flags

Implementation

Map<String, int> getServiceStatistics() {
  final stats = <String, int>{};

  for (final addr in addressList) {
    if (addr.services & ServiceFlags.nodeNetwork != 0) {
      stats['NODE_NETWORK'] = (stats['NODE_NETWORK'] ?? 0) + 1;
    }
    if (addr.services & ServiceFlags.nodeBloom != 0) {
      stats['NODE_BLOOM'] = (stats['NODE_BLOOM'] ?? 0) + 1;
    }
    if (addr.services & ServiceFlags.nodeWitness != 0) {
      stats['NODE_WITNESS'] = (stats['NODE_WITNESS'] ?? 0) + 1;
    }
    if (addr.services & ServiceFlags.nodeNetworkLimited != 0) {
      stats['NODE_NETWORK_LIMITED'] = (stats['NODE_NETWORK_LIMITED'] ?? 0) + 1;
    }
  }

  return stats;
}