Repository: Chia-Network/chia-blockchain
File: chia/full_node/tx_processing_queue.py (Python)

Code before:
                # we fallback to the highest cost.
                if tx_info is not None:
                    # At this point we have no transactions with zero cost
                    assert tx_info.advertised_cost > 0
                    top_tx_advertised_cost = tx_info.advertised_cost
                else:
                    top_tx_advertised_cost = self._max_tx_clvm_cost
                top_txs_advertised_costs[peer_id] = top_tx_advertised_cost
                if peer_queue.deficit >= top_tx_advertised_cost:
                    # This peer can afford its top transaction
                    _, entry = peer_queue.priority_queue.get()
                    peer_queue.deficit -= top_tx_advertised_cost
                    if peer_queue.priority_queue.empty():
                        peer_queue.deficit = 0
                    # Let's advance the cursor to the next peer
                    self._list_cursor = (peer_index + 1) % num_peers
                    # See if we need to perform the periodic cleanup
                    self._cleanup_counter = (self._cleanup_counter + 1) % 100
                    if self._cleanup_counter == 0:
                        self._cleanup_peer_queues()
                    return entry
            # None of the peers could afford to send their top transactions, so
            # let's add the lowest cost among transactions to all the deficit
            # counters for the next iteration.
            if len(top_txs_advertised_costs) == 0:
                assert False  # pragma: no cover
            lowest_cost_among_txs = min(top_txs_advertised_costs.values())
            for peer_id in top_txs_advertised_costs:
                self._peers_transactions_queues[peer_id].deficit += lowest_cost_among_txs


Review comment (suggestion):
```suggestion
            assert len(top_txs_advertised_costs) != 0
```

Code after:
                if tx_info is not None:
                    # At this point we have no transactions with zero cost
                    assert tx_info.advertised_cost > 0
                    top_tx_advertised_cost = tx_info.advertised_cost
                else:
                    top_tx_advertised_cost = self._max_tx_clvm_cost
                top_txs_advertised_costs[peer_id] = top_tx_advertised_cost
                if peer_queue.deficit >= top_tx_advertised_cost:
                    # This peer can afford its top transaction
                    _, entry = peer_queue.priority_queue.get()
                    peer_queue.deficit -= top_tx_advertised_cost
                    if peer_queue.priority_queue.empty():
                        peer_queue.deficit = 0
                    # Let's advance the cursor to the next peer
                    self._list_cursor = (peer_index + 1) % num_peers
                    # See if we need to perform the periodic cleanup
                    self._cleanup_counter = (self._cleanup_counter + 1) % 100
                    if self._cleanup_counter == 0:
                        self._cleanup_peer_queues()
                    return entry
            # None of the peers could afford to send their top transactions, so
            # let's add the lowest cost among transactions to all the deficit
            # counters for the next iteration.
            assert len(top_txs_advertised_costs) != 0
            lowest_cost_among_txs = min(top_txs_advertised_costs.values())
            for peer_id in top_txs_advertised_costs:
                self._peers_transactions_queues[peer_id].deficit += lowest_cost_among_txs