Document proofofwork public calls

This commit is contained in:
Lee Miller 2023-09-08 22:15:44 +03:00
parent 1139bdb8b7
commit ff63139d78
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -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()