@peer_required
@api_request
async def new_transaction(self, transaction: full_node_protocol.NewTransaction, peer: ws.WSChiaConnection) -> Optional[Message]:
    "\n        A peer notifies us of a new transaction.\n        Requests a full transaction if we haven't seen it previously, and if the fees are enough.\n        "
    if self.full_node.sync_store.get_sync_mode():
        return None
    if (not (await self.full_node.synced())):
        return None
    if self.full_node.mempool_manager.seen(transaction.transaction_id):
        return None
    if self.full_node.mempool_manager.is_fee_enough(transaction.fees, transaction.cost):
        if (transaction.transaction_id in self.full_node.full_node_store.pending_tx_request):
            if (transaction.transaction_id in self.full_node.full_node_store.peers_with_tx):
                current_set = self.full_node.full_node_store.peers_with_tx[transaction.transaction_id]
                if (peer.peer_node_id in current_set):
                    return None
                current_set.add(peer.peer_node_id)
                return None
            else:
                new_set = set()
                new_set.add(peer.peer_node_id)
                self.full_node.full_node_store.peers_with_tx[transaction.transaction_id] = new_set
                return None
        self.full_node.full_node_store.pending_tx_request[transaction.transaction_id] = peer.peer_node_id
        new_set = set()
        new_set.add(peer.peer_node_id)
        self.full_node.full_node_store.peers_with_tx[transaction.transaction_id] = new_set

        async def tx_request_and_timeout(full_node: FullNode, transaction_id, task_id):
            counter = 0
            try:
                while True:
                    if (counter == 5):
                        break
                    if (transaction_id not in full_node.full_node_store.peers_with_tx):
                        break
                    peers_with_tx: Set = full_node.full_node_store.peers_with_tx[transaction_id]
                    if (len(peers_with_tx) == 0):
                        break
                    peer_id = peers_with_tx.pop()
                    assert (full_node.server is not None)
                    if (peer_id not in full_node.server.all_connections):
                        continue
                    peer = full_node.server.all_connections[peer_id]
                    request_tx = full_node_protocol.RequestTransaction(transaction.transaction_id)
                    msg = make_msg(ProtocolMessageTypes.request_transaction, request_tx)
                    (await peer.send_message(msg))
                    (await asyncio.sleep(5))
                    counter += 1
                    if full_node.mempool_manager.seen(transaction_id):
                        break
            except asyncio.CancelledError:
                pass
            finally:
                if (transaction_id in full_node.full_node_store.peers_with_tx):
                    full_node.full_node_store.peers_with_tx.pop(transaction_id)
                if (transaction_id in full_node.full_node_store.pending_tx_request):
                    full_node.full_node_store.pending_tx_request.pop(transaction_id)
                if (task_id in full_node.full_node_store.tx_fetch_tasks):
                    full_node.full_node_store.tx_fetch_tasks.pop(task_id)
        task_id: bytes32 = bytes32(token_bytes(32))
        fetch_task = asyncio.create_task(tx_request_and_timeout(self.full_node, transaction.transaction_id, task_id))
        self.full_node.full_node_store.tx_fetch_tasks[task_id] = fetch_task
        return None
    return None
A peer notifies us of a new transaction.
Requests a full transaction if we haven't seen it previously, and if the fees are enough.
@peer_required
@api_request
async def new_transaction(self, transaction: full_node_protocol.NewTransaction, peer: ws.WSChiaConnection) -> Optional[Message]:
    "\n        A peer notifies us of a new transaction.\n        Requests a full transaction if we haven't seen it previously, and if the fees are enough.\n        "
    if self.full_node.sync_store.get_sync_mode():
        return None
    if (not (await self.full_node.synced())):
        return None
    if self.full_node.mempool_manager.seen(transaction.transaction_id):
        return None
    if self.full_node.mempool_manager.is_fee_enough(transaction.fees, transaction.cost):
        if (transaction.transaction_id in self.full_node.full_node_store.pending_tx_request):
            if (transaction.transaction_id in self.full_node.full_node_store.peers_with_tx):
                current_set = self.full_node.full_node_store.peers_with_tx[transaction.transaction_id]
                if (peer.peer_node_id in current_set):
                    return None
                current_set.add(peer.peer_node_id)
                return None
            else:
                new_set = set()
                new_set.add(peer.peer_node_id)
                self.full_node.full_node_store.peers_with_tx[transaction.transaction_id] = new_set
                return None
        self.full_node.full_node_store.pending_tx_request[transaction.transaction_id] = peer.peer_node_id
        new_set = set()
        new_set.add(peer.peer_node_id)
        self.full_node.full_node_store.peers_with_tx[transaction.transaction_id] = new_set

        async def tx_request_and_timeout(full_node: FullNode, transaction_id, task_id):
            counter = 0
            try:
                while True:
                    if (counter == 5):
                        break
                    if (transaction_id not in full_node.full_node_store.peers_with_tx):
                        break
                    peers_with_tx: Set = full_node.full_node_store.peers_with_tx[transaction_id]
                    if (len(peers_with_tx) == 0):
                        break
                    peer_id = peers_with_tx.pop()
                    assert (full_node.server is not None)
                    if (peer_id not in full_node.server.all_connections):
                        continue
                    peer = full_node.server.all_connections[peer_id]
                    request_tx = full_node_protocol.RequestTransaction(transaction.transaction_id)
                    msg = make_msg(ProtocolMessageTypes.request_transaction, request_tx)
                    (await peer.send_message(msg))
                    (await asyncio.sleep(5))
                    counter += 1
                    if full_node.mempool_manager.seen(transaction_id):
                        break
            except asyncio.CancelledError:
                pass
            finally:
                if (transaction_id in full_node.full_node_store.peers_with_tx):
                    full_node.full_node_store.peers_with_tx.pop(transaction_id)
                if (transaction_id in full_node.full_node_store.pending_tx_request):
                    full_node.full_node_store.pending_tx_request.pop(transaction_id)
                if (task_id in full_node.full_node_store.tx_fetch_tasks):
                    full_node.full_node_store.tx_fetch_tasks.pop(task_id)
        task_id: bytes32 = bytes32(token_bytes(32))
        fetch_task = asyncio.create_task(tx_request_and_timeout(self.full_node, transaction.transaction_id, task_id))
        self.full_node.full_node_store.tx_fetch_tasks[task_id] = fetch_task
        return None
    return None