From: Forrest Voight Date: Tue, 9 Aug 2011 08:20:35 +0000 (-0400) Subject: cleaned up parsing messages in bitcoin p2p protocol X-Git-Tag: 0.8.2~207^2~51 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=eed7e0679503595dc1c10a44ed9cc9987a303611;p=p2pool.git cleaned up parsing messages in bitcoin p2p protocol --- diff --git a/p2pool/bitcoin/p2p.py b/p2pool/bitcoin/p2p.py index bc2b5de..59df45c 100644 --- a/p2pool/bitcoin/p2p.py +++ b/p2pool/bitcoin/p2p.py @@ -62,14 +62,12 @@ class BaseProtocol(protocol.Protocol): if checksum is not None: if hashlib.sha256(hashlib.sha256(payload).digest()).digest()[:4] != checksum: - print 'RECV', command, checksum.encode('hex') if checksum is not None else None, repr(payload.encode('hex')), len(payload) - print 'INVALID HASH' + print 'invalid hash for', repr(command), checksum.encode('hex') if checksum is not None else None, repr(payload[:100].encode('hex')), len(payload) continue type_ = getattr(self, 'message_' + command, None) if type_ is None: - print 'RECV', command, checksum.encode('hex') if checksum is not None else None, repr(payload.encode('hex')), len(payload) - print 'NO TYPE FOR', repr(command) + print 'no type for', repr(command) continue try: @@ -81,16 +79,13 @@ class BaseProtocol(protocol.Protocol): handler = getattr(self, 'handle_' + command, None) if handler is None: - print 'RECV', command, checksum.encode('hex') if checksum is not None else None, repr(payload.encode('hex')), len(payload) - print 'NO HANDLER FOR', command + print 'no handler for', repr(command) continue - #print 'RECV', command, repr(payload2)[:500] - try: handler(**payload2) except: - print 'RECV', command, len(payload), checksum.encode('hex')[:1000] + print 'RECV', command, repr(payload2)[:100] log.err(None, 'Error handling message: (see RECV line)') continue