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

Function _checkAndShareGetpubkeyWithPeers

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

Source from the content-addressed store, hash-verified

462 objectProcessorQueue.put((objectType,data))
463
464def _checkAndShareGetpubkeyWithPeers(data):
465 if len(data) < 42:
466 logger.info('getpubkey message doesn\'t contain enough data. Ignoring.&#x27;)
467 return
468 if len(data) > 200:
469 logger.info('getpubkey is abnormally long. Sanity check failed. Ignoring object.')
470 embeddedTime, = unpack('>Q', data[8:16])
471 readPosition = 20 # bypass the nonce, time, and object type
472 requestedAddressVersionNumber, addressVersionLength = decodeVarint(
473 data[readPosition:readPosition + 10])
474 readPosition += addressVersionLength
475 streamNumber, streamNumberLength = decodeVarint(
476 data[readPosition:readPosition + 10])
477 if not streamNumber in state.streamsInWhichIAmParticipating:
478 logger.debug('The streamNumber %s isn\'t one we are interested in.&#x27;, streamNumber)
479 return
480 readPosition += streamNumberLength
481
482 inventoryHash = calculateInventoryHash(data)
483 if inventoryHash in Inventory():
484 logger.debug('We have already received this getpubkey request. Ignoring it.')
485 return
486
487 objectType = 0
488 Inventory()[inventoryHash] = (
489 objectType, streamNumber, data, embeddedTime,'')
490 # This getpubkey request is valid. Forward to peers.
491 logger.debug('advertising inv with hash: %s', hexlify(inventoryHash))
492 broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash))
493
494 # Now let's queue it to be processed ourselves.
495 objectProcessorQueue.put((objectType,data))
496
497def _checkAndSharePubkeyWithPeers(data):
498 if len(data) < 146 or len(data) > 440: # sanity check

Callers 1

Calls 5

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

Tested by

no test coverage detected