Skip to content

configs

configs

Synchronizer service configuration models.

See Also

Synchronizer: The service class that consumes these configurations. BaseServiceConfig: Base class providing interval and log_level fields.

Classes

FilterConfig

Bases: BaseModel

Nostr event filter configuration for sync subscriptions.

See Also

_create_filter: Converts this config into a nostr-sdk Filter object. SynchronizerConfig: Parent config that embeds this model.

Functions
validate_kinds classmethod
validate_kinds(v: list[int] | None) -> list[int] | None

Validate that all event kinds are within the valid range (0-65535).

Source code in src/bigbrotr/services/synchronizer/configs.py
@field_validator("kinds", mode="after")
@classmethod
def validate_kinds(cls, v: list[int] | None) -> list[int] | None:
    """Validate that all event kinds are within the valid range (0-65535)."""
    if v is None:
        return v
    for kind in v:
        if not 0 <= kind <= EVENT_KIND_MAX:
            raise ValueError(f"Event kind {kind} out of valid range (0-{EVENT_KIND_MAX})")
    return v
validate_hex_strings classmethod
validate_hex_strings(
    v: list[str] | None,
) -> list[str] | None

Validate that all entries are valid 64-character hex strings.

Source code in src/bigbrotr/services/synchronizer/configs.py
@field_validator("ids", "authors", mode="after")
@classmethod
def validate_hex_strings(cls, v: list[str] | None) -> list[str] | None:
    """Validate that all entries are valid 64-character hex strings."""
    if v is None:
        return v
    for hex_str in v:
        if len(hex_str) != _HEX_STRING_LENGTH:
            raise ValueError(
                f"Invalid hex string length: {len(hex_str)} (expected {_HEX_STRING_LENGTH})"
            )
        try:
            bytes.fromhex(hex_str)
        except ValueError as e:
            raise ValueError(f"Invalid hex string: {hex_str}") from e
    return v

TimeRangeConfig

Bases: BaseModel

Time range configuration controlling the sync window boundaries.

Note

When use_relay_state is True (the default), the sync start time is determined by the per-relay cursor plus one second (to avoid re-fetching the last event). When False, all relays start from default_start. The lookback_seconds parameter controls how far back from now() the sync window extends.

See Also

SynchronizerConfig: Parent config that embeds this model. get_all_service_cursors: Fetches the per-relay cursor values used when use_relay_state is enabled.

TimeoutsConfig

Bases: BaseModel

Per-relay sync timeout limits by network type.

These are the maximum total times allowed for syncing a single relay. The per-request WebSocket timeout comes from NetworksConfig.

See Also

SynchronizerConfig: Parent config that embeds this model.

Functions
get_relay_timeout
get_relay_timeout(network: NetworkType) -> float

Get the maximum sync duration for a relay on the given network.

Source code in src/bigbrotr/services/synchronizer/configs.py
def get_relay_timeout(self, network: NetworkType) -> float:
    """Get the maximum sync duration for a relay on the given network."""
    if network == NetworkType.TOR:
        return self.relay_tor
    if network == NetworkType.I2P:
        return self.relay_i2p
    if network == NetworkType.LOKI:
        return self.relay_loki
    return self.relay_clearnet

ConcurrencyConfig

Bases: BaseModel

Concurrency settings for parallel relay connections.

See Also

SynchronizerConfig: Parent config that embeds this model.

SourceConfig

Bases: BaseModel

Configuration for selecting which relays to sync from.

See Also

SynchronizerConfig: Parent config that embeds this model. get_all_relays: Query used when from_database is True.

RelayOverrideTimeouts

Bases: BaseModel

Per-relay timeout overrides (None means use the network default).

RelayOverride

Bases: BaseModel

Per-relay configuration overrides (e.g., for high-traffic relays).

SynchronizerConfig

Bases: BaseServiceConfig

Synchronizer service configuration.

See Also

Synchronizer: The service class that consumes this configuration. BaseServiceConfig: Base class providing interval and log_level fields. NetworksConfig: Per-network timeout and proxy settings. KeysConfig: Nostr key management for NIP-42 authentication during event fetching.