Skip to content

Instantly share code, notes, and snippets.

@dvf

dvf/blockchain.py

Last active Mar 31, 2021
Embed
What would you like to do?
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