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

Function _checkAndShareMsgWithPeers

src/protocol.py:438–462  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

436
437
438def _checkAndShareMsgWithPeers(data):
439 embeddedTime, = unpack('>Q', data[8:16])
440 readPosition = 20 # bypass nonce, time, and object type
441 objectVersion, objectVersionLength = decodeVarint(
442 data[readPosition:readPosition + 9])
443 readPosition += objectVersionLength
444 streamNumber, streamNumberLength = decodeVarint(
445 data[readPosition:readPosition + 9])
446 if not streamNumber in state.streamsInWhichIAmParticipating:
447 logger.debug('The streamNumber %s isn\'t one we are interested in.', streamNumber)
448 return
449 readPosition += streamNumberLength
450 inventoryHash = calculateInventoryHash(data)
451 if inventoryHash in Inventory():
452 logger.debug('We have already received this msg message. Ignoring.')
453 return
454 # This msg message is valid. Let's let our peers know about it.
455 objectType = 2
456 Inventory()[inventoryHash] = (
457 objectType, streamNumber, data, embeddedTime,'')
458 logger.debug('advertising inv with hash: %s', hexlify(inventoryHash))
459 broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash))
460
461 # Now let's enqueue it to be processed ourselves.
462 objectProcessorQueue.put((objectType,data))
463
464def _checkAndShareGetpubkeyWithPeers(data):
465 if len(data) < 42:

Callers 1

Calls 5

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

Tested by

no test coverage detected