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

Function _checkAndSharePubkeyWithPeers

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

Source from the content-addressed store, hash-verified

458 objectProcessorQueue.put((objectType,data))
459
460def _checkAndSharePubkeyWithPeers(data):
461 if len(data) < 146 or len(data) > 440: # sanity check
462 return
463 embeddedTime, = unpack('>Q', data[8:16])
464 readPosition = 20 # bypass the nonce, time, and object type
465 addressVersion, varintLength = decodeVarint(
466 data[readPosition:readPosition + 10])
467 readPosition += varintLength
468 streamNumber, varintLength = decodeVarint(
469 data[readPosition:readPosition + 10])
470 readPosition += varintLength
471 if not streamNumber in state.streamsInWhichIAmParticipating:
472 logger.debug('The streamNumber %s isn\'t one we are interested in.&#x27; % streamNumber)
473 return
474 if addressVersion >= 4:
475 tag = data[readPosition:readPosition + 32]
476 logger.debug('tag in received pubkey is: %s' % hexlify(tag))
477 else:
478 tag = ''
479
480 inventoryHash = calculateInventoryHash(data)
481 if inventoryHash in Inventory():
482 logger.debug('We have already received this pubkey. Ignoring it.')
483 return
484 objectType = 1
485 Inventory()[inventoryHash] = (
486 objectType, streamNumber, data, embeddedTime, tag)
487 # This object is valid. Forward it to peers.
488 logger.debug('advertising inv with hash: %s' % hexlify(inventoryHash))
489 protocol.broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash))
490
491
492 # Now let's queue it to be processed ourselves.
493 objectProcessorQueue.put((objectType,data))
494
495
496def _checkAndShareBroadcastWithPeers(data):

Callers 1

Calls 4

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

Tested by

no test coverage detected