MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / _checkAndShareMsgWithPeers

Function _checkAndShareMsgWithPeers

src/shared.py:403–427  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

401
402
403def _checkAndShareMsgWithPeers(data):
404 embeddedTime, = unpack('>Q', data[8:16])
405 readPosition = 20 # bypass nonce, time, and object type
406 objectVersion, objectVersionLength = decodeVarint(
407 data[readPosition:readPosition + 9])
408 readPosition += objectVersionLength
409 streamNumber, streamNumberLength = decodeVarint(
410 data[readPosition:readPosition + 9])
411 if not streamNumber in state.streamsInWhichIAmParticipating:
412 logger.debug('The streamNumber %s isn\'t one we are interested in.' % streamNumber)
413 return
414 readPosition += streamNumberLength
415 inventoryHash = calculateInventoryHash(data)
416 if inventoryHash in Inventory():
417 logger.debug('We have already received this msg message. Ignoring.')
418 return
419 # This msg message is valid. Let's let our peers know about it.
420 objectType = 2
421 Inventory()[inventoryHash] = (
422 objectType, streamNumber, data, embeddedTime,'')
423 logger.debug('advertising inv with hash: %s' % hexlify(inventoryHash))
424 protocol.broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash))
425
426 # Now let's enqueue it to be processed ourselves.
427 objectProcessorQueue.put((objectType,data))
428
429def _checkAndShareGetpubkeyWithPeers(data):
430 if len(data) < 42:

Callers 1

Calls 4

InventoryClass · 0.90
decodeVarintFunction · 0.85
calculateInventoryHashFunction · 0.85
putMethod · 0.80

Tested by

no test coverage detected