#NEWLINE# def processData( self ) : #NEWLINE# #INDENT# if ( len ( self . data ) < 20 ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( self . data [ 0 : 4 ] != MESSAGE_MAGIC_BYTES ) : #NEWLINE# #INDENT# safePrint ( 'Message did not begin with the necessary byte signature.  Not looking at this message.' ) #NEWLINE# self . data = '' #NEWLINE# return #NEWLINE# #UNINDENT# command = self . data [ 4 : 12 ] . decode ( ) . rstrip ( '\x00' ) #NEWLINE# payloadLength = unpack ( '>I' , self . data [ 12 : 16 ] ) [ 0 ] #NEWLINE# safePrint ( 'Payload is ' , payloadLength , ' bytes long.' ) #NEWLINE# payload = self . data [ 20 : ( 20 + payloadLength ) ] #NEWLINE# safePrint ( 'Payload = ' , payload ) #NEWLINE# checksum = hashlib . sha512 ( payload ) . digest ( ) [ 0 : 4 ] #NEWLINE# safePrint ( 'checksum = ' , checksum ) #NEWLINE# if ( self . data [ 16 : 20 ] != checksum ) : #NEWLINE# #INDENT# safePrint ( 'This message does not have the right checksum.  Exiting.' ) #NEWLINE# self . data = self . data [ ( 20 + payloadLength ) : ] #NEWLINE# self . processData ( ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( command == 'ver' ) : #NEWLINE# #INDENT# self . recVersion ( self ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( command == 'verack' ) : #NEWLINE# #INDENT# self . recVerack ( )