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

Function _checkAndShareGetpubkeyWithPeers

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

Source from the content-addressed store, hash-verified

427 objectProcessorQueue.put((objectType,data))
428
429def _checkAndShareGetpubkeyWithPeers(data):
430 if len(data) < 42:
431 logger.info('getpubkey message doesn\'t contain enough data. Ignoring.&#x27;)
432 return
433 embeddedTime, = unpack('>Q', data[8:16])
434 readPosition = 20 # bypass the nonce, time, and object type
435 requestedAddressVersionNumber, addressVersionLength = decodeVarint(
436 data[readPosition:readPosition + 10])
437 readPosition += addressVersionLength
438 streamNumber, streamNumberLength = decodeVarint(
439 data[readPosition:readPosition + 10])
440 if not streamNumber in state.streamsInWhichIAmParticipating:
441 logger.debug('The streamNumber %s isn\'t one we are interested in.&#x27; % streamNumber)
442 return
443 readPosition += streamNumberLength
444
445 inventoryHash = calculateInventoryHash(data)
446 if inventoryHash in Inventory():
447 logger.debug('We have already received this getpubkey request. Ignoring it.')
448 return
449
450 objectType = 0
451 Inventory()[inventoryHash] = (
452 objectType, streamNumber, data, embeddedTime,'')
453 # This getpubkey request is valid. Forward to peers.
454 logger.debug('advertising inv with hash: %s' % hexlify(inventoryHash))
455 protocol.broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash))
456
457 # Now let's queue it to be processed ourselves.
458 objectProcessorQueue.put((objectType,data))
459
460def _checkAndSharePubkeyWithPeers(data):
461 if len(data) < 146 or len(data) > 440: # sanity check

Callers 1

Calls 4

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

Tested by

no test coverage detected