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

Method recerror

src/class_receiveDataThread.py:454–483  ·  view source on GitHub ↗

The remote node has been polite enough to send you an error message.

(self, data)

Source from the content-addressed store, hash-verified

452 time.sleep(sleepTime)
453
454 def recerror(self, data):
455 """
456 The remote node has been polite enough to send you an error message.
457 """
458 fatalStatus, readPosition = decodeVarint(data[:10])
459 banTime, banTimeLength = decodeVarint(data[readPosition:readPosition+10])
460 readPosition += banTimeLength
461 inventoryVectorLength, inventoryVectorLengthLength = decodeVarint(data[readPosition:readPosition+10])
462 if inventoryVectorLength > 100:
463 return
464 readPosition += inventoryVectorLengthLength
465 inventoryVector = data[readPosition:readPosition+inventoryVectorLength]
466 readPosition += inventoryVectorLength
467 errorTextLength, errorTextLengthLength = decodeVarint(data[readPosition:readPosition+10])
468 if errorTextLength > 1000:
469 return
470 readPosition += errorTextLengthLength
471 errorText = data[readPosition:readPosition+errorTextLength]
472 if fatalStatus == 0:
473 fatalHumanFriendly = 'Warning'
474 elif fatalStatus == 1:
475 fatalHumanFriendly = 'Error'
476 elif fatalStatus == 2:
477 fatalHumanFriendly = 'Fatal'
478 message = '%s message received from %s: %s.' % (fatalHumanFriendly, self.peer, errorText)
479 if inventoryVector:
480 message += " This concerns object %s" % hexlify(inventoryVector)
481 if banTime > 0:
482 message += " Remote node says that the ban time is %s" % banTime
483 logger.error(message)
484
485
486 def recobject(self, data):

Callers 1

processDataMethod · 0.95

Calls 1

decodeVarintFunction · 0.85

Tested by

no test coverage detected