diff options
author | Jonas Schnelli <dev@jonasschnelli.ch> | 2016-03-29 14:30:02 +0200 |
---|---|---|
committer | Jonas Schnelli <dev@jonasschnelli.ch> | 2016-04-19 15:32:11 +0200 |
commit | 0b25a9fb42d5df54ea35ddb2bb4837e1e29355fd (patch) | |
tree | 429fe7843fbb85f3d46653381d0f82a39a4be595 /contrib/zmq | |
parent | de821d56e1f458fbe580520c77ac066107f4d77c (diff) |
[ZMQ] append a message sequence number to every ZMQ notification
Diffstat (limited to 'contrib/zmq')
-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: |