diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-19 15:36:58 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-19 15:44:38 +0200 |
commit | a1eb344ba8f4ef7dade755c823a9d001f837ae7d (patch) | |
tree | d063a57050a83688d042ceb308066c64dbbd9da8 /contrib | |
parent | 0e6fd5e4af31ada6da8df006801b59e9178ecd85 (diff) | |
parent | 0b25a9fb42d5df54ea35ddb2bb4837e1e29355fd (diff) |
Merge #7762: [ZMQ] append a message sequence number to every ZMQ notification
0b25a9f [ZMQ] append a message sequence number to every ZMQ notification (Jonas Schnelli)
de821d5 [ZMQ] refactor message string (Jonas Schnelli)
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/zmq/zmq_sub.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/contrib/zmq/zmq_sub.py b/contrib/zmq/zmq_sub.py index decf29d42a..6268123dd8 100755 --- a/contrib/zmq/zmq_sub.py +++ b/contrib/zmq/zmq_sub.py @@ -3,6 +3,7 @@ import array import binascii import zmq +import struct port = 28332 @@ -19,18 +20,21 @@ try: msg = zmqSubSocket.recv_multipart() topic = str(msg[0]) body = msg[1] - + sequence = "Unknown"; + if len(msg[-1]) == 4: + msgSequence = struct.unpack('<I', msg[-1])[-1] + sequence = str(msgSequence) if topic == "hashblock": - print "- HASH BLOCK -" + print '- HASH BLOCK ('+sequence+') -' print binascii.hexlify(body) elif topic == "hashtx": - print '- HASH TX -' + print '- HASH TX ('+sequence+') -' print binascii.hexlify(body) elif topic == "rawblock": - print "- RAW BLOCK HEADER -" + print '- RAW BLOCK HEADER ('+sequence+') -' print binascii.hexlify(body[:80]) elif topic == "rawtx": - print '- RAW TX -' + print '- RAW TX ('+sequence+') -' print binascii.hexlify(body) except KeyboardInterrupt: |