Last active
March 31, 2021 18:16
-
-
Save dvf/ae2c1ac5415fcd8fc3c9ce29d8e84211 to your computer and use it in GitHub Desktop.
Step 10: Registering Nodes
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
... | |
from urllib.parse import urlparse | |
... | |
class Blockchain(object): | |
def __init__(self): | |
... | |
self.nodes = set() | |
... | |
def register_node(self, address): | |
""" | |
Add a new node to the list of nodes | |
:param address: <str> Address of node. Eg. 'http://192.168.0.5:5000' | |
:return: None | |
""" | |
parsed_url = urlparse(address) | |
self.nodes.add(parsed_url.netloc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment