Created
September 19, 2018 23:58
-
-
Save lukas-hetzenecker/eef4bdd881d2bfa404155aab7ac491ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import binascii | |
import zmq | |
import struct | |
import csv | |
import time | |
from iota import Address, ProposedTransaction, Tag, Transaction | |
port = 5556 | |
def zmq_tx_consumer(): | |
zmqContext = zmq.Context() | |
zmqSubSocket = zmqContext.socket(zmq.SUB) | |
zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"tx_trytes") | |
#zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"sn") | |
zmqSubSocket.connect("tcp://192.168.22.11:%i" % port) | |
try: | |
while True: | |
msg = zmqSubSocket.recv() | |
print(msg) | |
topic, data, hash_ = msg.split(b' ') | |
tx = Transaction.from_tryte_string(data) | |
print(vars(tx)) | |
except KeyboardInterrupt: | |
zmqContext.destroy() | |
if __name__ == '__main__': | |
print("Starting ZMQ Listener...") | |
zmq_tx_consumer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment