constants
constants
¶
Shared constants for the models layer.
Defines enumerations and other constants that are used across multiple model modules. Placing them here avoids circular dependencies between the models and utils layers.
See Also
bigbrotr.models.relay: Uses NetworkType to classify relay URLs during construction. bigbrotr.nips.nip66: Relies on network type for overlay-specific health checks. bigbrotr.models.service_state: Uses ServiceName and imports EventKind for service state types.
Classes¶
NetworkType
¶
Bases: StrEnum
Network type enum for relay classification.
Each relay URL is classified into exactly one network type during
Relay construction. The scheme is then
enforced per network: clearnet requires wss:// (TLS), while overlay
networks use ws:// (encryption handled by the overlay).
Attributes:
-
CLEARNET–Public internet relay using
wss://(TLS required). -
TOR–Tor hidden service identified by a
.onionhostname. -
I2P–I2P eepsite identified by a
.i2phostname. -
LOKI–Lokinet service identified by a
.lokihostname. -
LOCAL–Private or reserved IP address (rejected during validation).
-
UNKNOWN–Hostname that could not be classified (rejected during validation).
Examples:
Network detection is performed by
Relay._detect_network():
Relay("wss://relay.damus.io").network # NetworkType.CLEARNET
Relay("ws://abc123.onion").network # NetworkType.TOR
Relay("ws://relay.i2p").network # NetworkType.I2P
Warning
LOCAL and UNKNOWN network types cause Relay
construction to raise ValueError. They exist for internal detection logic
and are never exposed on a successfully constructed instance.
See Also
Relay: Performs network detection and scheme enforcement. RelayDbParams: Stores the network type as a string for database persistence.
ServiceName
¶
Bases: StrEnum
Canonical service identifiers used in logging, metrics, and persistence.
Each member corresponds to one of the six services. The string
values are used as the service_name column in the service_state
table and as the service label in Prometheus metrics.
Attributes:
-
SEEDER–One-shot bootstrapping service (Seeder).
-
FINDER–Continuous relay URL discovery service (Finder).
-
VALIDATOR–WebSocket-based Nostr protocol validation service (Validator).
-
MONITOR–NIP-11 / NIP-66 health monitoring service (Monitor).
-
SYNCHRONIZER–Cursor-based event collection service (Synchronizer).
-
REFRESHER–Periodic materialized view refresh service (Refresher).
See Also
BaseService: Abstract
base class that uses SERVICE_NAME for logging context.
queries: SQL functions that
filter service_state rows by service name.
EventKind
¶
Bases: IntEnum
Well-known Nostr event kinds used across services.
Each member corresponds to a NIP-defined event kind that BigBrotr processes or publishes.
Attributes:
-
SET_METADATA–Kind 0 -- user profile metadata (NIP-01).
-
RECOMMEND_RELAY–Kind 2 -- legacy relay recommendation (NIP-01, deprecated).
-
CONTACTS–Kind 3 -- contact list with relay hints (NIP-02).
-
RELAY_LIST–Kind 10002 -- NIP-65 relay list metadata.
-
NIP66_TEST–Kind 22456 -- ephemeral NIP-66 relay test event.
-
MONITOR_ANNOUNCEMENT–Kind 10166 -- NIP-66 monitor announcement (replaceable, published by the Monitor service).
-
RELAY_DISCOVERY–Kind 30166 -- NIP-66 relay discovery event (parameterized replaceable, published by the Monitor service).
See Also
Event: The event wrapper that carries
these kinds.
EVENT_KIND_MAX: Maximum valid event kind value (65535).