added some more readmes

This commit is contained in:
Kevin Froman 2019-08-07 17:46:57 -05:00
parent 636cf3a8d1
commit 76356d5e3f
6 changed files with 37 additions and 8 deletions

View file

@ -5,11 +5,11 @@ Onionr communicator is the Onionr client. It "connects" to remote Onionr peers a
* Finding new peers
* Uploading blocks
* Downloading blocks
* Daemon maintnence/housekeeping
* Daemon maintenance/housekeeping
## Files
* \_\_init\_\_.py: Contains the main communicator code. Inits and launches the communicator and sets up the timers
* peeraction.py: contains a function to send commands to remote peers
* bootstrappers.py: adds peers from the bootstrap list to the communicator to try to connect to them
* onlinepers: management of the online peer pool for the communicator
* onlinepeers: management of the online peer pool for the communicator

View file

@ -0,0 +1,12 @@
# Online Peers
Manages a pool of peers to perform actions with. Since Onionr does not maintain socket connections, it holds a list of peers.
## Files
* \_\_init\_\_.py: exposes some functions to interact with the pool
* clearofflinepeer.py: Pop the oldest peer in the offline list
* onlinepeers.py: communicator timer to add new peers to the pool randomly
* pickonlinepeers.py: returns a random peer from the online pool
* removeonlinepeer.py: removes a specified peer from the online pool

View file

@ -20,16 +20,16 @@
import secrets
def pick_online_peer(comm_inst):
'''randomly picks peer from pool without bias (using secrets module)'''
retData = ''
ret_data = ''
while True:
peerLength = len(comm_inst.onlinePeers)
if peerLength <= 0:
peer_length = len(comm_inst.onlinePeers)
if peer_length <= 0:
break
try:
# get a random online peer, securely. May get stuck in loop if network is lost or if all peers in pool magically disconnect at once
retData = comm_inst.onlinePeers[secrets.randbelow(peerLength)]
ret_data = comm_inst.onlinePeers[secrets.randbelow(peer_length)]
except IndexError:
pass
else:
break
return retData
return ret_data