# Path: pycoinnet/InvItem.py
# class InvItem(object):
#     def __init__(self, item_type, data):
#         self.item_type = item_type
#         self.data = data
# 
#     def __str__(self):
#         INV_TYPES = [None, "Tx", "Block", "Merkle"]
#         return "%s [%s]" % (INV_TYPES[self.item_type], b2h_rev(self.data))
# 
#     def __repr__(self):
#         return str(self)
# 
#     def __hash__(self):
#         return hash(self.data)
# 
#     def __eq__(self, other):
#         if isinstance(other, self.__class__):
#             return self.item_type == other.item_type and self.data == other.data
#         else:
#             return False
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def stream(self, f):
#         stream_struct("L#", f, self.item_type, self.data)
# 
#     @classmethod
#     def parse(self, f):
#         return self(*parse_struct("L#", f))
# 
# Path: pycoinnet/PeerAddress.py
# class PeerAddress(object):
#     def __init__(self, services, ip_int_or_str, port):
#         ip_address = ipaddress.ip_address(ip_int_or_str)
#         self.services = services
#         self.ip_address = ip_address
#         self.port = port
# 
#     def __repr__(self):
#         return "%s/%d" % (self.ip_address, self.port)
# 
#     def host(self):
#         return self.ip_address.exploded
# 
#     def stream(self, f):
#         f.write(struct.pack("<Q", self.services))
#         ip_bin = self.ip_address.packed
#         if len(ip_bin) < 16:
#             f.write(IP4_HEADER)
#         f.write(ip_bin)
#         f.write(struct.pack("!H", self.port))
# 
#     @classmethod
#     def parse(self, f):
#         services, ip_bin, port = parse_struct("Q@h", f)
#         if ip_bin.startswith(IP4_HEADER):
#             ip_bin = ip_bin[len(IP4_HEADER):]
#         ip_int = int.from_bytes(ip_bin, byteorder="big")
#         return self(services, ip_int, port)
# 
#     def __lt__(self, other):
#         return self.ip_address.packed < other.ip_address.packed
# 
#     def __eq__(self, other):
#         return self.services == other.services and \
#             self.ip_address == other.ip_address and self.port == other.port


import binascii
import logging
import io
import struct
from pycoin.block import Block, BlockHeader
from pycoin.encoding import double_sha256
from pycoin.serialize import b2h_rev, bitcoin_streamer
from pycoin.tx.Tx import Tx
from pycoinnet.InvItem import InvItem
from pycoinnet.PeerAddress import PeerAddress

    d["tx_hashes"] = tx_acc
    return d


def _message_fixups():
    def fixup_version(d, f):
        if d["version"] >= 70001:
            b = f.read(1)
            if len(b) > 0:
                d["relay"] = (ord(b) != 0)
        return d

    alert_submessage_parser = _make_parser(
        "version:L relayUntil:Q expiration:Q id:L cancel:L setCancel:[L] minVer:L "
        "maxVer:L setSubVer:[S] priority:L comment:S statusBar:S reserved:S")

    def fixup_alert(d, f):
        d1 = alert_submessage_parser(io.BytesIO(d["payload"]))
        d["alert_info"] = d1
        return d

    return dict(version=fixup_version, alert=fixup_alert, merkleblock=fixup_merkleblock)


def _make_parse_from_data():

    def init_bitcoin_streamer():
        more_parsing = [
            ("A", (PeerAddress.parse, lambda f, peer_addr: peer_addr.stream(f))),

# Path: pycoinnet/InvItem.py
# class InvItem(object):
#     def __init__(self, item_type, data):
#         self.item_type = item_type
#         self.data = data
# 
#     def __str__(self):
#         INV_TYPES = [None, "Tx", "Block", "Merkle"]
#         return "%s [%s]" % (INV_TYPES[self.item_type], b2h_rev(self.data))
# 
#     def __repr__(self):
#         return str(self)
# 
#     def __hash__(self):
#         return hash(self.data)
# 
#     def __eq__(self, other):
#         if isinstance(other, self.__class__):
#             return self.item_type == other.item_type and self.data == other.data
#         else:
#             return False
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def stream(self, f):
#         stream_struct("L#", f, self.item_type, self.data)
# 
#     @classmethod
#     def parse(self, f):
#         return self(*parse_struct("L#", f))
# 
# Path: pycoinnet/PeerAddress.py
# class PeerAddress(object):
#     def __init__(self, services, ip_int_or_str, port):
#         ip_address = ipaddress.ip_address(ip_int_or_str)
#         self.services = services
#         self.ip_address = ip_address
#         self.port = port
# 
#     def __repr__(self):
#         return "%s/%d" % (self.ip_address, self.port)
# 
#     def host(self):
#         return self.ip_address.exploded
# 
#     def stream(self, f):
#         f.write(struct.pack("<Q", self.services))
#         ip_bin = self.ip_address.packed
#         if len(ip_bin) < 16:
#             f.write(IP4_HEADER)
#         f.write(ip_bin)
#         f.write(struct.pack("!H", self.port))
# 
#     @classmethod
#     def parse(self, f):
#         services, ip_bin, port = parse_struct("Q@h", f)
#         if ip_bin.startswith(IP4_HEADER):
#             ip_bin = ip_bin[len(IP4_HEADER):]
#         ip_int = int.from_bytes(ip_bin, byteorder="big")
#         return self(services, ip_int, port)
# 
#     def __lt__(self, other):
#         return self.ip_address.packed < other.ip_address.packed
# 
#     def __eq__(self, other):
#         return self.services == other.services and \
#             self.ip_address == other.ip_address and self.port == other.port


# Path: pycoinnet/message.py
import binascii
import logging
import io
import struct
from pycoin.block import Block, BlockHeader
from pycoin.encoding import double_sha256
from pycoin.serialize import b2h_rev, bitcoin_streamer
from pycoin.tx.Tx import Tx
from pycoinnet.InvItem import InvItem
from pycoinnet.PeerAddress import PeerAddress


    d["tx_hashes"] = tx_acc
    return d


def _message_fixups():
    def fixup_version(d, f):
        if d["version"] >= 70001:
            b = f.read(1)
            if len(b) > 0:
                d["relay"] = (ord(b) != 0)
        return d

    alert_submessage_parser = _make_parser(
        "version:L relayUntil:Q expiration:Q id:L cancel:L setCancel:[L] minVer:L "
        "maxVer:L setSubVer:[S] priority:L comment:S statusBar:S reserved:S")

    def fixup_alert(d, f):
        d1 = alert_submessage_parser(io.BytesIO(d["payload"]))
        d["alert_info"] = d1
        return d

    return dict(version=fixup_version, alert=fixup_alert, merkleblock=fixup_merkleblock)


def _make_parse_from_data():

    def init_bitcoin_streamer():
        more_parsing = [
            ("A", (PeerAddress.parse, lambda f, peer_addr: peer_addr.stream(f))),

            ("v", (InvItem.parse, lambda f, inv_item: inv_item.stream(f))),