Skip to content

Instantly share code, notes, and snippets.

@dvf
Last active March 31, 2021 18:16
Show Gist options
  • Save dvf/ae2c1ac5415fcd8fc3c9ce29d8e84211 to your computer and use it in GitHub Desktop.
Save dvf/ae2c1ac5415fcd8fc3c9ce29d8e84211 to your computer and use it in GitHub Desktop.
Step 10: Registering Nodes
...
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