pybitmessage.threads module

PyBitmessage does various tasks in separate threads. Most of them inherit from network.StoppableThread. There are addressGenerator for addresses generation, objectProcessor for processing the network objects passed minimal validation, singleCleaner to periodically clean various internal storages (like inventory and knownnodes) and do forced garbage collection, singleWorker for doing PoW, sqlThread for querying sqlite database.

There are also other threads in the network package.

set_thread_name() is defined here for the threads that don’t inherit from network.StoppableThread

class addressGenerator(name=None)[source]

Bases: pybitmessage.network.threads.StoppableThread

A thread for creating addresses

name = 'addressGenerator'
stopThread()

Stop the thread

run()

Process the requests for addresses generation from queues.addressGeneratorQueue

class objectProcessor[source]

Bases: threading.Thread

The objectProcessor thread, of which there is only one, receives network objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads.

run()

Process the objects from queues.objectProcessorQueue

static checkackdata(data)

Checking Acknowledgement of message received or not?

static processonion(data)

Process onionpeer object

static processgetpubkey(data)

Process getpubkey object

processpubkey(data)

Process a pubkey object

processmsg(data)

Process a message object

processbroadcast(data)

Process a broadcast object

possibleNewPubkey(address)

We have inserted a pubkey into our pubkey table which we received from a pubkey, msg, or broadcast message. It might be one that we have been waiting for. Let’s check.

static sendMessages(address)

This method is called by the possibleNewPubkey when it sees that we now have the necessary pubkey to send one or more messages.

static ackDataHasAValidHeader(ackData)

Checking ackData with valid Header, not sending ackData when false

static addMailingListNameToSubject(subject, mailingListName)

Adding mailingListName to subject

class singleCleaner(name=None)[source]

Bases: pybitmessage.network.threads.StoppableThread

The singleCleaner thread class

name = 'singleCleaner'
cycleLength = 300
expireDiscoveredPeers = 300
run()

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.

resendPubkeyRequest(address)

Resend pubkey request for address

resendMsg(ackdata)

Resend message by ackdata

class singleWorker[source]

Bases: pybitmessage.network.threads.StoppableThread

Thread for performing PoW

stopThread()

Signal through the queue that the thread should be stopped

run()

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.

doPOWForMyV2Pubkey(adressHash)

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

sendOutOrStoreMyV3Pubkey(adressHash)

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 it in the pubkey table so that we can send messages to “ourselves”.

sendOutOrStoreMyV4Pubkey(myAddress)

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.

sendOnionPeerObj(peer=None)

Send onionpeer object representing peer

sendBroadcast()

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

sendMsg()

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

requestPubKey(toAddress)

Send a getpubkey object

generateFullAckMessage(ackdata, TTL)

Create ACK packet

class sqlThread[source]

Bases: threading.Thread

A thread for all SQL operations

run()

Process SQL queries from helper_sql.sqlSubmitQueue

create_function()