Document proofofwork public calls
This commit is contained in:
parent
1139bdb8b7
commit
ff63139d78
|
@ -30,6 +30,7 @@ def _pow_worker(target, initial_hash, q):
|
|||
|
||||
|
||||
class Worker(threading.Thread):
|
||||
"""The thread doind PoW for objects and publishing them"""
|
||||
def __init__(self, obj=None):
|
||||
self.obj = obj
|
||||
super().__init__(
|
||||
|
@ -73,6 +74,10 @@ class Worker(threading.Thread):
|
|||
return nonce
|
||||
|
||||
def add_pow(self, obj):
|
||||
"""
|
||||
Do PoW for the given object and return a new `.structure.Object`
|
||||
- with the proper nonce and vector.
|
||||
"""
|
||||
t = time.time()
|
||||
if not self.bmpow:
|
||||
logging.debug('Starting PoW process')
|
||||
|
@ -105,4 +110,9 @@ class Worker(threading.Thread):
|
|||
|
||||
|
||||
def do_pow_and_publish(obj):
|
||||
"""
|
||||
Start a worker thread doing PoW for the given object
|
||||
and putting a new object and its vector into appropriate places in `shared`
|
||||
to advertize to the network.
|
||||
"""
|
||||
Worker(obj).start()
|
||||
|
|
Loading…
Reference in New Issue
Block a user