pybitmessage.class_singleWorker module

Thread for performing PoW

sizeof_fmt(num, suffix='h/s')[source]

Format hashes per seconds nicely (SI prefix)

class singleWorker[source]


Thread for performing PoW


Signal through the queue that the thread should be stopped


Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.


This function also broadcasts out the pubkey message once it is done with the POW


If this isn’t a chan address, this function assembles the pubkey data, does the necessary POW and sends it out. If it is a chan then it assembles the pubkey and stores is in the pubkey table so that we can send messages to “ourselves”.


It doesn’t send directly anymore. It put is to a queue for another thread to send at an appropriate time, whereas in the past it directly appended it to the outgoing buffer, I think. Same with all the other methods in this class.


Send onionpeer object representing peer


Send a broadcast-type object (assemble the object, perform PoW and put it to the inv announcement queue)


Send a message-type object (assemble the object, perform PoW and put it to the inv announcement queue)


Send a getpubkey object

generateFullAckMessage(ackdata, _, TTL)

It might be perfectly fine to just use the same TTL for the ackdata that we use for the message. But I would rather it be more difficult for attackers to associate ackData with the associated msg object. However, users would want the TTL of the acknowledgement to be about the same as they set for the message itself. So let’s set the TTL of the acknowledgement to be in one of three ‘buckets’: 1 hour, 7 days, or 28 days, whichever is relatively close to what the user specified.