pybitmessage.network.bmproto module

Class BMProto defines bitmessage’s network protocol workflow.

exception BMProtoError(code=-1)[source]

Bases: network.proxy.ProxyError

A Bitmessage Protocol Base Error

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

Bases: pybitmessage.network.bmproto.BMProtoError

A Bitmessage Protocol Insufficient Data Error

errorCodes = 'Insufficient data'
exception BMProtoExcessiveDataError(code=-1)[source]

Bases: pybitmessage.network.bmproto.BMProtoError

A Bitmessage Protocol Excessive Data Error

errorCodes = 'Too much data'
class BMProto(address=None, sock=None)[source]

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

A parser for the Bitmessage Protocol

timeOffsetWrongCount = 0
bm_proto_reset()

Reset the bitmessage object parser

state_bm_header()

Process incoming header

state_bm_command()

Process incoming command

decode_payload_string(length)

Read and return length bytes from payload

decode_payload_varint()

Decode a varint from the payload

decode_payload_node()

Decode node details from the payload

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

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

Dandelion stem announce

bm_command_object()

Incoming object, process it

bm_command_addr()

Incoming addresses, process them

bm_command_portcheck()

Incoming port check request, queue it.

bm_command_ping()

Incoming ping, respond to it.

static 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_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.

peerValidityChecks()

Check the validity of the peer

static stopDownloadingObject(hashId, forwardAnyway=False)

Stop downloading object hashId

handle_close()

Handle close