Пример #1
0
 def _process_version_handshake(socket):
     data=socket.recv(1024)
     if(protocol.compare_command(data,"version")):
         print("version message recieved")
     else:
         print("unexpected message recieved")
     data=socket.recv(1024)
     out_tuple=struct.unpack('<I12c',data[0:16]) 
     if(protocol.compare_command(data,"verack")):
         print("verack message recieved")
     else: 
         print("message type:",out_tuple[1:])
Пример #2
0
 def _process_version_handshake(socket):
     data=socket.recv(1024)
     if(protocol.compare_command(data,"version")):
         logging.info("version message recieved")
     else:
         logging.error("unexpected message recieved in version handshake")
     data=socket.recv(1024)
     out_tuple=struct.unpack('<I12c',data[0:16]) 
     if(protocol.compare_command(data,"verack")):
         logging.info("verack message recieved")
     else: 
         logging.info("message type:",out_tuple[1:])
Пример #3
0
 def _process_pong(data):
     if(protocol.compare_command(data,"pong")):
         return True
     else:
         return False 
Пример #4
0
 def process_data(self,data):
     if protocol.compare_command(data,"getaddr"): #get known peers
         pass
     elif protocol.compare_command(data,"addr"):#in reponse to getaddr
         self._process_addr(data)
     elif protocol.compare_command(data,"version"):
         pass
     elif protocol.compare_command(data,"verack"):
         pass
     elif protocol.compare_command(data,"inv"): #advertise knowledge of tx or block
         self._process_inv(data)
     elif protocol.compare_command(data,"getblocks"):#request an inv packet for blocks
         pass
     elif protocol.compare_command(data,"getheaders"):#request headers
         pass
     elif protocol.compare_command(data,"headers"):#return header in reponse to getheader
         pass
     elif protocol.compare_command(data,"getdata"):#get data from peer after broadcasting tx via inv
         self._process_get_data(data)  
     elif protocol.compare_command(data,"notfound"):#not found is sent after getdata recieved
         pass
     elif protocol.compare_command(data,"block"):#describe a block in reponse to getdata
         pass
     elif protocol.compare_command(data,"tx"):#describe a transaction in repones to getdata
         pass
     elif protocol.compare_command(data,"pong"):#response to ping
         pass
     elif protocol.compare_command(data,"ping"):#query if tcp ip is alive
         pass
     else:
         print("unhandled command recieved:",protocol.get_command_msgheader(data))
Пример #5
0
 def _process_pong(data):
     if(protocol.compare_command(data,"pong")):
         return True
     else:
         return False 
Пример #6
0
 def process_data(self,data):
     if protocol.compare_command(data,"getaddr"): #get known peers
         pass
     elif protocol.compare_command(data,"addr"):#in reponse to getaddr
         self._process_addr(data)
     elif protocol.compare_command(data,"version"):
         pass
     elif protocol.compare_command(data,"verack"):
         pass
     elif protocol.compare_command(data,"inv"): #advertise knowledge of tx or block
         self._process_inv(data)
     elif protocol.compare_command(data,"getblocks"):#request an inv packet for blocks
         pass
     elif protocol.compare_command(data,"getheaders"):#request headers
         pass
     elif protocol.compare_command(data,"headers"):#return header in reponse to getheader
         pass
     elif protocol.compare_command(data,"getdata"):#get data from peer after broadcasting tx via inv
         self._process_get_data(data)  
     elif protocol.compare_command(data,"notfound"):#not found is sent after getdata recieved
         pass
     elif protocol.compare_command(data,"block"):#describe a block in reponse to getdata
         pass
     elif protocol.compare_command(data,"tx"):#describe a transaction in repones to getdata
         pass
     elif protocol.compare_command(data,"pong"):#response to ping
         pass
     elif protocol.compare_command(data,"ping"):#query if tcp ip is alive
         pass
     elif protocol.compare_command(data,"reject"): 
         self._process_reject(data)
     elif (self.crypto in ['dashpay','dashpay_testnet'] and 
           protocol.compare_command(data,'dseep')):
         pass
     else:
         logging.warn("unhandled command recieved:{}".format(
                                 protocol.get_command_msgheader(data)))