@ -1749,7 +1749,7 @@ class NodeConn(asyncore.dispatcher):
def send_message ( self , message , pushbuf = False ) :
def send_message ( self , message , pushbuf = False ) :
if self . state != " connected " and not pushbuf :
if self . state != " connected " and not pushbuf :
raise IOError ( ' Not connected, no pushbuf ' )
raise IOError ( ' Not connected, no pushbuf ' )
logger . debug ( " Send message to %s : %d : %s " % ( self . dstaddr , self . dstport , repr ( message ) ) )
self . _log_message ( " send " , message )
command = message . command
command = message . command
data = message . serialize ( )
data = message . serialize ( )
tmsg = self . MAGIC_BYTES [ self . network ]
tmsg = self . MAGIC_BYTES [ self . network ]
@ -1771,9 +1771,19 @@ class NodeConn(asyncore.dispatcher):
self . messagemap [ b ' ping ' ] = msg_ping_prebip31
self . messagemap [ b ' ping ' ] = msg_ping_prebip31
if self . last_sent + 30 * 60 < time . time ( ) :
if self . last_sent + 30 * 60 < time . time ( ) :
self . send_message ( self . messagemap [ b ' ping ' ] ( ) )
self . send_message ( self . messagemap [ b ' ping ' ] ( ) )
logger . debug ( " Received message from %s : %d : %s " % ( self . dstaddr , self . dstport , repr ( message ) ) )
self . _log_message ( " receive " , message )
self . cb . deliver ( self , message )
self . cb . deliver ( self , message )
def _log_message ( self , direction , msg ) :
if direction == " send " :
log_message = " Send message to "
elif direction == " receive " :
log_message = " Received message from "
log_message + = " %s : %d : %s " % ( self . dstaddr , self . dstport , repr ( msg ) [ : 500 ] )
if len ( log_message ) > 500 :
log_message + = " ... (msg truncated) "
logger . debug ( log_message )
def disconnect_node ( self ) :
def disconnect_node ( self ) :
self . disconnect = True
self . disconnect = True