pybitmessage.network.bmproto module

src/network/bmproto.py

class BMProto(address=None, sock=None)[source]

Bases: network.advanceddispatcher.AdvancedDispatcher, pybitmessage.network.objectracker.ObjectTracker

A parser for the Bitmessage Protocol

addressAlive = 10800
static assembleAddr(peerList)

Build up a packed address

bm_command_addr()

Incoming addresses, process them

bm_command_dinv()

Dandelion stem announce

bm_command_error()

Decode an error message and log it

bm_command_getdata()

Incoming request for object(s). If we have them and some other conditions are fulfilled, append them to the write queue.

bm_command_inv()

Non-dandelion announce

bm_command_object()

Incoming object, process it

bm_command_ping()

Incoming ping, respond to it.

bm_command_pong()

Incoming pong. Ignore it. PyBitmessage pings connections after about 5 minutes of inactivity, and leaves it to the TCP stack to handle actual timeouts. So there is no need to do anything when a pong arrives.

bm_command_portcheck()

Incoming port check request, queue it.

bm_command_verack()

Incoming verack. If already sent my own verack, handshake is complete (except potentially waiting for buffers to flush), so we can continue to the main connection phase. If not sent verack yet, continue processing.

bm_command_version()

Incoming version. Parse and log, remember important things, like streams, bitfields, etc.

bm_proto_reset()

Reset the bitmessage object parser

decode_payload_content(pattern='v')

Decode the payload depending on pattern:

L = varint indicating the length of the next array l = varint indicating the length of the next item v = varint (or array) H = uint16 I = uint32 Q = uint64 i = net_addr (without time and stream number) s = string 0-9 = length of the next item , = end of array

decode_payload_node()

Decode node details from the payload

decode_payload_string(length)

Read and return length bytes from payload

decode_payload_varint()

Decode a varint from the payload

handle_close()

Handle close

maxAddrCount = 1000
maxMessageSize = 1600100
maxObjectCount = 50000
maxObjectPayloadSize = 262144
maxTimeOffset = 3600
peerValidityChecks()

Check the validity of the peer

state_bm_command()

Process incoming command

state_bm_header()

Process incoming header

static stopDownloadingObject(hashId, forwardAnyway=False)

Stop downloading an object

timeOffsetWrongCount = 0
exception BMProtoError(code=-1)[source]

Bases: network.proxy.ProxyError

A Bitmessage Protocol Base Error

errorCodes = 'Protocol error'
exception BMProtoExcessiveDataError(code=-1)[source]

Bases: pybitmessage.network.bmproto.BMProtoError

A Bitmessage Protocol Excessive Data Error

errorCodes = 'Too much data'
exception BMProtoInsufficientDataError(code=-1)[source]

Bases: pybitmessage.network.bmproto.BMProtoError

A Bitmessage Protocol Insufficient Data Error

errorCodes = 'Insufficient data'
class BMStringParser[source]

Bases: pybitmessage.network.bmproto.BMProto

A special case of BMProto used by objectProcessor to send ACK

send_data(data)

Send object given by the data string