getSeedNodes static method

Future<List<String>?> getSeedNodes({
  1. List<String>? seedNodes,
  2. bool? disableP2p,
  3. bool fetchRemote = true,
})

Gets seed nodes based on configuration preferences.

This is a convenience method that determines the appropriate seed nodes based on P2P settings and provided seed nodes.

Returns:

  • null if P2P is disabled
  • Provided seedNodes if they are specified
  • Remote seed nodes if fetchRemote is true
  • Default seed nodes as fallback

Implementation

static Future<List<String>?> getSeedNodes({
  List<String>? seedNodes,
  bool? disableP2p,
  bool fetchRemote = true,
}) async {
  // If P2P is disabled, no seed nodes are needed
  if (disableP2p == true) {
    return null;
  }

  // Use explicitly provided seed nodes if available
  if (seedNodes != null && seedNodes.isNotEmpty) {
    return seedNodes;
  }

  // Fetch remote seed nodes or use defaults
  if (fetchRemote) {
    final result = await fetchSeedNodes();
    return result.seedNodes;
  } else {
    return getDefaultSeedNodes();
  }
}