"""Ingest into storage all events matching an arbitrary NIP-01 filter.

Thin wrapper over ``daemon.req_and_ingest``: the filter is forwarded
verbatim to every active relay (no key whitelist — relays decide what they
accept), responses are upserted via the storage hook, and a per-relay
delivery report is returned.
"""

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from ingest_sql import IngestDaemonSQL


def run(daemon: "IngestDaemonSQL", flt: dict) -> dict:
    result = daemon.req_and_ingest(flt)
    return {
        "filter": flt,
        "relays": result["relays"],
        "unique_events": result["unique_events"],
    }
