(data)
| 494 | |
| 495 | |
| 496 | def _checkAndShareBroadcastWithPeers(data): |
| 497 | if len(data) < 180: |
| 498 | logger.debug('The payload length of this broadcast packet is unreasonably low. Someone is probably trying funny business. Ignoring message.') |
| 499 | return |
| 500 | embeddedTime, = unpack('>Q', data[8:16]) |
| 501 | readPosition = 20 # bypass the nonce, time, and object type |
| 502 | broadcastVersion, broadcastVersionLength = decodeVarint( |
| 503 | data[readPosition:readPosition + 10]) |
| 504 | readPosition += broadcastVersionLength |
| 505 | if broadcastVersion >= 2: |
| 506 | streamNumber, streamNumberLength = decodeVarint(data[readPosition:readPosition + 10]) |
| 507 | readPosition += streamNumberLength |
| 508 | if not streamNumber in state.streamsInWhichIAmParticipating: |
| 509 | logger.debug('The streamNumber %s isn\'t one we are interested in.' % streamNumber) |
| 510 | return |
| 511 | if broadcastVersion >= 3: |
| 512 | tag = data[readPosition:readPosition+32] |
| 513 | else: |
| 514 | tag = '' |
| 515 | inventoryHash = calculateInventoryHash(data) |
| 516 | if inventoryHash in Inventory(): |
| 517 | logger.debug('We have already received this broadcast object. Ignoring.') |
| 518 | return |
| 519 | # It is valid. Let's let our peers know about it. |
| 520 | objectType = 3 |
| 521 | Inventory()[inventoryHash] = ( |
| 522 | objectType, streamNumber, data, embeddedTime, tag) |
| 523 | # This object is valid. Forward it to peers. |
| 524 | logger.debug('advertising inv with hash: %s' % hexlify(inventoryHash)) |
| 525 | protocol.broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash)) |
| 526 | |
| 527 | # Now let's queue it to be processed ourselves. |
| 528 | objectProcessorQueue.put((objectType,data)) |
| 529 | |
| 530 | def openKeysFile(): |
| 531 | if 'linux' in sys.platform: |
no test coverage detected