cosme12 / SimpleCoin

Just a really simple, insecure and incomplete implementation of a blockchain for a cryptocurrency made in Python as educational material. In other words, a simple Bitcoin clone.
http://copitosystem.com
MIT License
1.78k stars 397 forks source link

Add new peer nodes dynamically #4

Open cosme12 opened 6 years ago

cosme12 commented 6 years ago

Apart from having a few hard coded nodes, there should be a simple system that add new trusted peer nodes.

kennethgoodman commented 6 years ago

Something simple:

peers = []
nodes = initial_nodes
while len(peers) < number_of_peers_needed: # keep going till you find your peers
     new_nodes = [] # recreate list of nodes to check
     For node in nodes: # for each of those nodes
        if random.random() < .1: # randomly pick those to add as a peer
            peers.append(node) 
        else: # if you don't pick that node, check all of their peers
            new_nodes.append( node.peers() )
     nodes = new_nodes

I can submit a pull request for this

Abdur-rahmaanJ commented 6 years ago

*dynamically

ghost commented 5 years ago

I also think this should be added, like it works with bitcoin.