Remove unused var UNLIKELY_PCT from fees.h
[bitcoinplatinum.git] / contrib / zmq / zmq_sub.py
blob3dea5e3c1440cc6ddb7b57530e577bed5bf461e0
1 #!/usr/bin/env python2
2 # Copyright (c) 2014-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 import array
7 import binascii
8 import zmq
9 import struct
11 port = 28332
13 zmqContext = zmq.Context()
14 zmqSubSocket = zmqContext.socket(zmq.SUB)
15 zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashblock")
16 zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashtx")
17 zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "rawblock")
18 zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "rawtx")
19 zmqSubSocket.connect("tcp://127.0.0.1:%i" % port)
21 try:
22 while True:
23 msg = zmqSubSocket.recv_multipart()
24 topic = str(msg[0])
25 body = msg[1]
26 sequence = "Unknown";
27 if len(msg[-1]) == 4:
28 msgSequence = struct.unpack('<I', msg[-1])[-1]
29 sequence = str(msgSequence)
30 if topic == "hashblock":
31 print '- HASH BLOCK ('+sequence+') -'
32 print binascii.hexlify(body)
33 elif topic == "hashtx":
34 print '- HASH TX ('+sequence+') -'
35 print binascii.hexlify(body)
36 elif topic == "rawblock":
37 print '- RAW BLOCK HEADER ('+sequence+') -'
38 print binascii.hexlify(body[:80])
39 elif topic == "rawtx":
40 print '- RAW TX ('+sequence+') -'
41 print binascii.hexlify(body)
43 except KeyboardInterrupt:
44 zmqContext.destroy()