# Path: pycoinnet/InvItem.py
# ITEM_TYPE_TX, ITEM_TYPE_BLOCK, ITEM_TYPE_MERKLEBLOCK = (1, 2, 3)
#         INV_TYPES = [None, "Tx", "Block", "Merkle"]
# class InvItem(object):
#     def __init__(self, item_type, data):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def stream(self, f):
#     def parse(self, f):


import asyncio
import logging
from pycoinnet.InvItem import InvItem, ITEM_TYPE_TX

    def add_peer(self, peer):
        """
        Call this method when a peer comes online and you want to keep its mempool
        in sync with this mempool.
        """
        @asyncio.coroutine
        def _run_getdata(next_message):
            while True:
                name, data = yield from next_message()
                inv_items = data["items"]
                not_found = []
                txs_found = []
                for inv_item in inv_items:
                    if inv_item.item_type != ITEM_TYPE_TX:
                        continue
                    tx = self.tx_store.get(inv_item.data)
                    if tx:
                        txs_found.append(tx)
                    else:
                        not_found.append(inv_item)
                if not_found:
                    peer.send_msg("notfound", items=not_found)
                for tx in txs_found:
                    peer.send_msg("tx", tx=tx)

        @asyncio.coroutine
        def _run_mempool(next_message):
            try:
                name, data = yield from next_message()

# Path: pycoinnet/InvItem.py
# ITEM_TYPE_TX, ITEM_TYPE_BLOCK, ITEM_TYPE_MERKLEBLOCK = (1, 2, 3)
#         INV_TYPES = [None, "Tx", "Block", "Merkle"]
# class InvItem(object):
#     def __init__(self, item_type, data):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def stream(self, f):
#     def parse(self, f):


# Path: pycoinnet/peergroup/TxHandler.py
import asyncio
import logging
from pycoinnet.InvItem import InvItem, ITEM_TYPE_TX


    def add_peer(self, peer):
        """
        Call this method when a peer comes online and you want to keep its mempool
        in sync with this mempool.
        """
        @asyncio.coroutine
        def _run_getdata(next_message):
            while True:
                name, data = yield from next_message()
                inv_items = data["items"]
                not_found = []
                txs_found = []
                for inv_item in inv_items:
                    if inv_item.item_type != ITEM_TYPE_TX:
                        continue
                    tx = self.tx_store.get(inv_item.data)
                    if tx:
                        txs_found.append(tx)
                    else:
                        not_found.append(inv_item)
                if not_found:
                    peer.send_msg("notfound", items=not_found)
                for tx in txs_found:
                    peer.send_msg("tx", tx=tx)

        @asyncio.coroutine
        def _run_mempool(next_message):
            try:
                name, data = yield from next_message()

                inv_items = [InvItem(ITEM_TYPE_TX, tx.hash()) for tx in self.tx_store.values()]