nectar.nodelist module
- class nectar.nodelist.NodeList
Bases:
listSimplified Hive node list using PeakD beacon API.
Fetches real-time node information from PeakD beacon API with static fallback.
from nectar.nodelist import NodeList n = NodeList() nodes_urls = n.get_nodes()
- get_hive_nodes(testnet: bool = False, not_working: bool = False, wss: bool = True, https: bool = True) List[str]
Return a list of Hive node URLs filtered and ordered by score.
- Args:
testnet: Include testnet nodes (default: False) not_working: Include nodes with negative scores (default: False) wss: Include WebSocket nodes (default: True) https: Include HTTPS nodes (default: True)
- Returns:
List of Hive node URLs sorted by score
- get_node_answer_time(node_list: List[str] | None = None, verbose: bool = False) List[Dict[str, float]]
Get node response times (deprecated with beacon API).
The beacon API already provides performance scoring, so this method returns the beacon scores instead of measuring response times.
- Args:
node_list: List of node URLs to check (ignored, uses all nodes) verbose: Log node information (default: False)
- Returns:
List of dictionaries with ‘url’ and ‘delay_ms’ keys
- get_nodes(hive: bool = True, dev: bool = False, testnet: bool = False, testnetdev: bool = False, wss: bool = True, https: bool = True, not_working: bool = False, normal: bool = False, appbase: bool = True) List[str]
Return a list of node URLs filtered and sorted by score.
- Args:
hive: Filter for Hive nodes only (default: True) dev: Include dev nodes (not applicable with beacon) testnet: Include testnet nodes (not applicable with beacon) testnetdev: Include testnet dev nodes (not applicable with beacon) wss: Include WebSocket nodes (default: True) https: Include HTTPS nodes (default: True) not_working: Include nodes with negative scores (default: False) normal: Include normal nodes (deprecated, default: False) appbase: Include appbase nodes (default: True)
- Returns:
List of node URLs sorted by score (highest first)
- get_testnet(testnet: bool = True, testnetdev: bool = False) List[str]
Return a list of testnet node URLs (currently unavailable).
Note: The PeakD beacon API does not provide testnet nodes. This method currently returns an empty list. Use mainnet nodes for testing or manually configure testnet endpoints.
- Args:
testnet: Include testnet nodes (default: True) testnetdev: Include testnet dev nodes (default: False)
- Returns:
List of testnet node URLs
- update(node_list: List[str]) None
Update node list (not implemented with beacon API).
- Args:
node_list: List of node URLs (ignored with beacon API)
- update_nodes(weights: Any = None, blockchain_instance: Any = None) None
Refresh nodes from beacon API.
This method replaces the complex update logic with a simple refresh from the beacon API and clears the cache to force fresh data.
- Args:
weights: Ignored (beacon provides its own scoring) blockchain_instance: Ignored (beacon API is independent)
- nectar.nodelist.clear_beacon_cache() None
Clear the cached beacon node data.
This forces the next NodeList() instantiation or update_nodes() call to fetch fresh data from the beacon API.
- nectar.nodelist.extract_nodes_from_raw(raw: Any, source: str) List[Dict[str, Any]] | None
- nectar.nodelist.fetch_beacon_nodes() List[Dict[str, Any]] | None
Fetch node list from PeakD beacon API with caching.
- Returns:
List of node dictionaries from beacon API, or None if fetch fails