Crate fedimint_eventlog

Source
Expand description

Client Event Log

The goal here is to maintain a single, ordered, append only log of all important client-side events: low or high level, and move as much of coordination between different parts of the system in a natural and decomposed way.

Any event log “follower” can just keep going through all events and react to ones it is interested in (and understands), potentially emitting events of its own, and atomically updating persisted event log position (“cursor”) of events that were already processed.

Structs§

EventKind
EventLogEntry
EventLogId
Ordered, contiguous ID space, which is easy for event log followers to track.
EventLogIdPrefix
EventLogIdPrefixAll
EventLogTrimableId
EventLogTrimableIdPrefix
EventLogTrimableIdPrefixAll
PersistedLogEntry
Struct used for processing log entries after they have been persisted.
StructuredPaymentEvents
Helper struct for storing computed data about outgoing and incoming payments.
UnordedEventLogId
A self-allocated ID that is mostly ordered
UnorderedEventLogEntry
UnorderedEventLogIdPrefixAll

Enums§

EventPersistence

Constants§

DB_KEY_PREFIX_EVENT_LOG
DB_KEY_PREFIX_EVENT_LOG_TRIMABLE
DB_KEY_PREFIX_UNORDERED_EVENT_LOG
DB prefixes hardcoded for use of the event log fedimint-eventlog was extracted from fedimint-client to help include/re-use in other part of the code. But fundamentally its role is to implement event log in the client. There is currently no way to inject the prefixes to use for db records, so we use these constants to keep them in sync. Any other app that will want to store its own even log, will need to use the exact same prefixes, which in practice should not be a problem.
TRIMABLE_EVENTLOG_MAX_TRIMMED_EVENTS 🔒
Maximum number of entries to trim in one operation
TRIMABLE_EVENTLOG_MIN_ID_AGE 🔒
Minimum age in ID count for trimable events to be deleted
TRIMABLE_EVENTLOG_MIN_TS_AGE 🔒
Minimum age in microseconds for trimable events to be deleted (14 days)

Statics§

UNORDEREDED_EVENT_LOG_ID_COUNTER 🔒
An counter that resets on every restart, that guarantees that UnordedEventLogIds don’t conflict with each other.

Traits§

DBTransactionEventLogExt
Event

Functions§

filter_events_by_kind
Filters the PersistedLogEntries by the EventKind and ModuleKind.
handle_events
handle_trimable_events
join_events
Joins two sets of events on a predicate.
run_event_log_ordering_task
The code that handles new unordered events and rewriters them fully ordered into the final event log.
trim_trimable_log 🔒
Trims old entries from the trimable event log