-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract logic for checking new node providers to separate file
- Loading branch information
1 parent
9066663
commit 23d21fb
Showing
3 changed files
with
26 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
node_monitor/node_monitor_helpers/get_new_node_providers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Dict, List, Any | ||
from node_monitor.ic_api import NodeProvider | ||
|
||
Principal = str | ||
|
||
def get_new_node_providers( | ||
node_providers_api_dict: Dict[Principal, str], | ||
node_providers_db: Dict[Principal, Dict[str, Any]], | ||
) -> List[NodeProvider]: | ||
principals_api = set(node_providers_api_dict.keys()) | ||
principals_db = set(node_providers_db.keys()) | ||
principals_new = principals_api - principals_db | ||
|
||
node_providers_new = [ | ||
NodeProvider( | ||
display_name=node_providers_api_dict[principal_id], | ||
principal_id=principal_id | ||
) for principal_id in principals_new | ||
] | ||
|
||
return node_providers_new |