pybitmessage.network.knownnodes module

Manipulations with knownNodes dictionary.

knownNodesLock = <_RLock owner=None count=0>[source]

Thread lock for knownnodes modification

knownNodes = {1: {}, 2: {}, 3: {}}[source]

The dict of known nodes for each stream

knownNodesTrimAmount = 2000[source]

trim stream knownnodes dict to this length

knownNodesForgetRating = -0.5[source]

forget a node after rating is this low

json_serialize_knownnodes(output)[source]

Reorganize knownnodes dict and write it as JSON to output

json_deserialize_knownnodes(source)[source]

Read JSON from source and make knownnodes dict

pickle_deserialize_old_knownnodes(source)[source]

Unpickle source and reorganize knownnodes dict if it has old format the old format was {Peer:lastseen, …} the new format is {Peer:{“lastseen”:i, “rating”:f}}

saveKnownNodes(dirName=None)[source]

Save knownnodes to filesystem

addKnownNode(stream, peer, lastseen=None, is_self=False)[source]

Add a new node to the dict or update lastseen if it already exists. Do it for each stream number if stream is Iterable. Returns True if added a new node.

createDefaultKnownNodes()[source]

Creating default Knownnodes

readKnownNodes()[source]

Load knownnodes from filesystem

increaseRating(peer)[source]

Increase rating of a peer node

decreaseRating(peer)[source]

Decrease rating of a peer node

trimKnownNodes(recAddrStream=1)[source]

Triming Knownnodes

dns()[source]

Add DNS names to knownnodes

cleanupKnownNodes()[source]

Cleanup knownnodes: remove old nodes and nodes with low rating