Documentation
¶
Index ¶
- Constants
- Variables
- type B
- func (b *B) AddNIP43Member(pubkey []byte, inviteCode string) error
- func (b *B) BuildIndexes(ctx context.Context) error
- func (b *B) CacheEvents(f *filter.F, events event.S)
- func (b *B) CacheMarshaledJSON(f *filter.F, marshaledJSON [][]byte)
- func (b *B) CheckForDeleted(ev *event.E, admins [][]byte) error
- func (b *B) Close() (err error)
- func (b *B) CountEvents(c context.Context, f *filter.F) (count int, approximate bool, err error)
- func (b *B) DeleteEvent(c context.Context, eid []byte) error
- func (b *B) DeleteEventBySerial(c context.Context, ser *types.Uint40, ev *event.E) error
- func (b *B) DeleteExpired()
- func (b *B) DeleteInviteCode(code string) error
- func (b *B) DeleteMarker(key string) error
- func (b *B) EdgeExists(srcSerial, dstSerial uint64, edgeType byte) (bool, error)
- func (b *B) EventIdsBySerial(start uint64, count int) (evs []uint64, err error)
- func (b *B) Export(c context.Context, w io.Writer, pubkeys ...[]byte)
- func (b *B) ExtendBlossomSubscription(pubkey []byte, tier string, storageMB int64, daysExtended int) error
- func (b *B) ExtendSubscription(pubkey []byte, days int) error
- func (b *B) FetchEventBySerial(ser *types.Uint40) (ev *event.E, err error)
- func (b *B) FetchEventsBySerials(serials []*types.Uint40) (events map[uint64]*event.E, err error)
- func (b *B) FindEventByAuthorAndKind(authorSerial uint64, kindNum uint16) (uint64, error)
- func (b *B) GetAllNIP43Members() ([][]byte, error)
- func (b *B) GetBlossomStorageQuota(pubkey []byte) (quotaMB int64, err error)
- func (b *B) GetCachedEvents(f *filter.F) (event.S, bool)
- func (b *B) GetCachedJSON(f *filter.F) ([][]byte, bool)
- func (b *B) GetETagsFromEvent(eventSerial uint64) ([]uint64, error)
- func (b *B) GetEventAccessInfo(serial uint64) (lastAccess int64, accessCount uint32, err error)
- func (b *B) GetEventVertex(eventSerial uint64) (*EventVertex, error)
- func (b *B) GetEventsAuthoredBy(pubkeySerial uint64) ([]uint64, error)
- func (b *B) GetEventsMentioning(pubkeySerial uint64) ([]uint64, error)
- func (b *B) GetFollowsFromPubkeySerial(pubkeySerial *types.Uint40) ([]*types.Uint40, error)
- func (b *B) GetFullIdPubkeyBySerial(ser *types.Uint40) (fidpk *store.IdPkTs, err error)
- func (b *B) GetFullIdPubkeyBySerials(sers []*types.Uint40) (fidpks []*store.IdPkTs, err error)
- func (b *B) GetLeastAccessedEvents(limit int, minAgeSec int64) (serials []uint64, err error)
- func (b *B) GetMarker(key string) (value []byte, err error)
- func (b *B) GetNIP43Membership(pubkey []byte) (*database.NIP43Membership, error)
- func (b *B) GetOrCreateRelayIdentitySecret() (skb []byte, err error)
- func (b *B) GetPTagsFromEvent(eventSerial uint64) ([]uint64, error)
- func (b *B) GetPaymentHistory(pubkey []byte) ([]database.Payment, error)
- func (b *B) GetPubkeyVertex(pubkeySerial uint64) (*PubkeyVertex, error)
- func (b *B) GetReferencingEvents(targetSerial uint64) ([]uint64, error)
- func (b *B) GetRelayIdentitySecret() (skb []byte, err error)
- func (b *B) GetSerialById(id []byte) (ser *types.Uint40, err error)
- func (b *B) GetSerialsByIds(ids *tag.T) (serials map[string]*types.Uint40, err error)
- func (b *B) GetSerialsByIdsWithFilter(ids *tag.T, fn func(ev *event.E, ser *types.Uint40) bool) (serials map[string]*types.Uint40, err error)
- func (b *B) GetSerialsByRange(idx database.Range) (serials types.Uint40s, err error)
- func (b *B) GetSerialsFromFilter(f *filter.F) (sers types.Uint40s, err error)
- func (b *B) GetSubscription(pubkey []byte) (*database.Subscription, error)
- func (b *B) HasMarker(key string) bool
- func (b *B) Import(rr io.Reader)
- func (b *B) ImportEventsFromReader(ctx context.Context, rr io.Reader) error
- func (b *B) ImportEventsFromStrings(ctx context.Context, eventJSONs []string, policyManager interface{ ... }) error
- func (b *B) Init(path string) error
- func (b *B) InvalidateQueryCache()
- func (b *B) IsFirstTimeUser(pubkey []byte) (bool, error)
- func (b *B) IsNIP43Member(pubkey []byte) (isMember bool, err error)
- func (b *B) IsSubscriptionActive(pubkey []byte) (bool, error)
- func (b *B) Path() string
- func (b *B) ProcessDelete(ev *event.E, admins [][]byte) error
- func (b *B) PublishNIP43MembershipEvent(kind int, pubkey []byte) error
- func (b *B) QueryAllVersions(c context.Context, f *filter.F) (evs event.S, err error)
- func (b *B) QueryDeleteEventsByTargetId(c context.Context, targetEventId []byte) (evs event.S, err error)
- func (b *B) QueryEvents(c context.Context, f *filter.F) (evs event.S, err error)
- func (b *B) QueryEventsWithOptions(c context.Context, f *filter.F, includeDeleteEvents bool, showAllVersions bool) (evs event.S, err error)
- func (b *B) QueryForIds(c context.Context, f *filter.F) (idPkTs []*store.IdPkTs, err error)
- func (b *B) QueryForSerials(c context.Context, f *filter.F) (serials types.Uint40s, err error)
- func (b *B) Ready() <-chan struct{}
- func (b *B) RecordEventAccess(serial uint64, connectionID string) error
- func (b *B) RecordPayment(pubkey []byte, amount int64, invoice, preimage string) error
- func (b *B) RemoveNIP43Member(pubkey []byte) error
- func (b *B) RunMigrations()
- func (b *B) SaveEvent(c context.Context, ev *event.E) (replaced bool, err error)
- func (b *B) SaveEventForImport(ev *event.E) error
- func (b *B) SaveEventMinimal(ev *event.E) error
- func (b *B) SetLogLevel(level string)
- func (b *B) SetMarker(key string, value []byte) error
- func (b *B) SetRelayIdentitySecret(skb []byte) error
- func (b *B) StoreInviteCode(code string, expiresAt time.Time) error
- func (b *B) Sync() error
- func (b *B) ValidateInviteCode(code string) (valid bool, err error)
- func (b *B) Wipe() error
- func (b *B) WouldReplaceEvent(ev *event.E) (bool, types.Uint40s, error)
- type BatchedWrite
- type BatcherStats
- type BboltConfig
- type BloomStats
- type EdgeBloomFilter
- func (ebf *EdgeBloomFilter) Add(srcSerial, dstSerial uint64, edgeType byte)
- func (ebf *EdgeBloomFilter) AddBatch(edges []EdgeKey)
- func (ebf *EdgeBloomFilter) MayExist(srcSerial, dstSerial uint64, edgeType byte) bool
- func (ebf *EdgeBloomFilter) Persist(db *bolt.DB) error
- func (ebf *EdgeBloomFilter) Reset()
- func (ebf *EdgeBloomFilter) Stats() BloomStats
- type EdgeKey
- type EventBatch
- type EventVertex
- type Logger
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) SetLogLevel(level int)
- func (l *Logger) Tracef(format string, args ...interface{})
- func (l *Logger) Warningf(format string, args ...interface{})
- type PubkeyVertex
- func (pv *PubkeyVertex) AddAuthored(eventSerial uint64)
- func (pv *PubkeyVertex) AddMention(eventSerial uint64)
- func (pv *PubkeyVertex) Decode(data []byte) error
- func (pv *PubkeyVertex) Encode() []byte
- func (pv *PubkeyVertex) HasAuthored(eventSerial uint64) bool
- func (pv *PubkeyVertex) IsMentionedIn(eventSerial uint64) bool
- func (pv *PubkeyVertex) RemoveAuthored(eventSerial uint64)
- func (pv *PubkeyVertex) RemoveMention(eventSerial uint64)
- type PubkeyVertexUpdate
- type WriteBatcher
Constants ¶
const ( EdgeTypeAuthor byte = 0 // Event author relationship EdgeTypePTag byte = 1 // P-tag reference (event mentions pubkey) EdgeTypeETag byte = 2 // E-tag reference (event references event) EdgeTypeFollows byte = 3 // Kind 3 follows relationship EdgeTypeReaction byte = 4 // Kind 7 reaction EdgeTypeRepost byte = 5 // Kind 6 repost EdgeTypeReply byte = 6 // Reply (kind 1 with e-tag) )
Edge type constants
Variables ¶
var ErrBatcherStopped = &batcherStoppedError{}
ErrBatcherStopped is returned when adding to a stopped batcher
Functions ¶
This section is empty.
Types ¶
type B ¶
type B struct {
Logger *Logger
// contains filtered or unexported fields
}
B implements the database.Database interface using BBolt as the storage backend. Optimized for HDD with write batching and adjacency list graph storage.
func New ¶
func New( ctx context.Context, cancel context.CancelFunc, dataDir, logLevel string, ) (b *B, err error)
New creates a new BBolt database instance with default configuration.
func NewWithConfig ¶
func NewWithConfig( ctx context.Context, cancel context.CancelFunc, cfg *BboltConfig, ) (b *B, err error)
NewWithConfig creates a new BBolt database instance with full configuration.
func (*B) AddNIP43Member ¶
AddNIP43Member adds a NIP-43 member.
func (*B) BuildIndexes ¶ added in v0.48.8
BuildIndexes builds all query indexes from stored events. Call this after importing events with SaveEventMinimal. Processes events in chunks to avoid OOM on large databases.
func (*B) CacheEvents ¶
CacheEvents caches events for a filter (stub - no caching in bbolt).
func (*B) CacheMarshaledJSON ¶
CacheMarshaledJSON caches JSON for a filter (stub - no caching in bbolt).
func (*B) CheckForDeleted ¶
CheckForDeleted checks if an event has been deleted.
func (*B) CountEvents ¶
CountEvents counts events matching a filter.
func (*B) DeleteEvent ¶
DeleteEvent deletes an event by ID.
func (*B) DeleteEventBySerial ¶
DeleteEventBySerial deletes an event by serial.
func (*B) DeleteInviteCode ¶
DeleteInviteCode deletes an invite code.
func (*B) EdgeExists ¶
EdgeExists checks if an edge exists between two serials. Uses bloom filter for fast negative lookups.
func (*B) EventIdsBySerial ¶
EventIdsBySerial gets event IDs by serial range.
func (*B) Export ¶
Export exports events to a writer.
func (*B) ExtendBlossomSubscription ¶
func (b *B) ExtendBlossomSubscription(pubkey []byte, tier string, storageMB int64, daysExtended int) error
ExtendBlossomSubscription extends a Blossom subscription.
func (*B) ExtendSubscription ¶
ExtendSubscription extends a subscription.
func (*B) FetchEventBySerial ¶
FetchEventBySerial fetches an event by its serial number.
func (*B) FetchEventsBySerials ¶
FetchEventsBySerials fetches multiple events by their serial numbers.
func (*B) FindEventByAuthorAndKind ¶
FindEventByAuthorAndKind finds an event serial by author and kind. For replaceable events like kind-3, returns the most recent one.
func (*B) GetAllNIP43Members ¶
GetAllNIP43Members gets all NIP-43 members.
func (*B) GetBlossomStorageQuota ¶
GetBlossomStorageQuota gets Blossom storage quota.
func (*B) GetCachedEvents ¶
GetCachedEvents gets cached events for a filter (stub - no caching in bbolt).
func (*B) GetCachedJSON ¶
GetCachedJSON gets cached JSON for a filter (stub - no caching in bbolt).
func (*B) GetETagsFromEvent ¶
GetETagsFromEvent returns event serials referenced by an event.
func (*B) GetEventAccessInfo ¶
GetEventAccessInfo gets event access information.
func (*B) GetEventVertex ¶
func (b *B) GetEventVertex(eventSerial uint64) (*EventVertex, error)
GetEventVertex retrieves the adjacency list for an event.
func (*B) GetEventsAuthoredBy ¶
GetEventsAuthoredBy returns event serials authored by a pubkey.
func (*B) GetEventsMentioning ¶
GetEventsMentioning returns event serials that mention a pubkey.
func (*B) GetFollowsFromPubkeySerial ¶
GetFollowsFromPubkeySerial returns the pubkey serials that a user follows. This extracts p-tags from the user's kind-3 contact list event.
func (*B) GetFullIdPubkeyBySerial ¶
GetFullIdPubkeyBySerial gets full event ID and pubkey by serial.
func (*B) GetFullIdPubkeyBySerials ¶
GetFullIdPubkeyBySerials gets full event IDs and pubkeys for multiple serials.
func (*B) GetLeastAccessedEvents ¶
GetLeastAccessedEvents gets least accessed events.
func (*B) GetMarker ¶
GetMarker gets a metadata marker.
func (*B) GetNIP43Membership ¶
func (b *B) GetNIP43Membership(pubkey []byte) (*database.NIP43Membership, error)
GetNIP43Membership gets NIP-43 membership details.
func (*B) GetOrCreateRelayIdentitySecret ¶
GetOrCreateRelayIdentitySecret gets or creates the relay's identity secret.
func (*B) GetPTagsFromEvent ¶
GetPTagsFromEvent returns pubkey serials tagged in an event.
func (*B) GetPaymentHistory ¶
GetPaymentHistory gets payment history.
func (*B) GetPubkeyVertex ¶
func (b *B) GetPubkeyVertex(pubkeySerial uint64) (*PubkeyVertex, error)
GetPubkeyVertex retrieves the adjacency list for a pubkey.
func (*B) GetReferencingEvents ¶
GetReferencingEvents returns event serials that reference a target event via e-tag.
func (*B) GetRelayIdentitySecret ¶
GetRelayIdentitySecret gets the relay's identity secret key.
func (*B) GetSerialById ¶
GetSerialById gets the serial for an event ID.
func (*B) GetSerialsByIds ¶
GetSerialsByIds gets serials for multiple event IDs.
func (*B) GetSerialsByIdsWithFilter ¶
func (b *B) GetSerialsByIdsWithFilter(ids *tag.T, fn func(ev *event.E, ser *types.Uint40) bool) (serials map[string]*types.Uint40, err error)
GetSerialsByIdsWithFilter gets serials with a filter function.
func (*B) GetSerialsByRange ¶
GetSerialsByRange gets serials within a key range.
func (*B) GetSerialsFromFilter ¶
GetSerialsFromFilter returns serials matching a filter.
func (*B) GetSubscription ¶
func (b *B) GetSubscription(pubkey []byte) (*database.Subscription, error)
GetSubscription gets a user's subscription.
func (*B) Import ¶
Import imports events from a reader (legacy interface).
func (*B) ImportEventsFromReader ¶
ImportEventsFromReader imports events from an io.Reader containing JSONL data
func (*B) ImportEventsFromStrings ¶
func (b *B) ImportEventsFromStrings(ctx context.Context, eventJSONs []string, policyManager interface { CheckPolicy(action string, ev *event.E, pubkey []byte, remote string) (bool, error) }) error
ImportEventsFromStrings imports events from a slice of JSON strings with policy filtering
func (*B) Init ¶
Init initializes the database with the given path.
func (*B) InvalidateQueryCache ¶
func (b *B) InvalidateQueryCache()
InvalidateQueryCache invalidates the query cache (stub - no caching in bbolt).
func (*B) IsFirstTimeUser ¶
IsFirstTimeUser checks if this is a first-time user.
func (*B) IsNIP43Member ¶
IsNIP43Member checks if pubkey is a NIP-43 member.
func (*B) IsSubscriptionActive ¶
IsSubscriptionActive checks if a subscription is active.
func (*B) Path ¶
Path returns the path where the database files are stored.
func (*B) ProcessDelete ¶
ProcessDelete processes a deletion event. For migration from other backends, deletions have already been processed, so this is a no-op. Full implementation needed for production use.
func (*B) PublishNIP43MembershipEvent ¶
PublishNIP43MembershipEvent publishes a NIP-43 membership event.
func (*B) QueryAllVersions ¶
QueryAllVersions queries all versions of events matching a filter.
func (*B) QueryDeleteEventsByTargetId ¶
func (b *B) QueryDeleteEventsByTargetId(c context.Context, targetEventId []byte) (evs event.S, err error)
QueryDeleteEventsByTargetId queries delete events targeting a specific event.
func (*B) QueryEvents ¶
QueryEvents queries events matching a filter.
func (*B) QueryEventsWithOptions ¶
func (b *B) QueryEventsWithOptions(c context.Context, f *filter.F, includeDeleteEvents bool, showAllVersions bool) (evs event.S, err error)
QueryEventsWithOptions queries events with additional options.
func (*B) QueryForIds ¶
QueryForIds queries and returns event ID/pubkey/timestamp tuples.
func (*B) QueryForSerials ¶
QueryForSerials queries and returns only the serials.
func (*B) Ready ¶
func (b *B) Ready() <-chan struct{}
Ready returns a channel that closes when the database is ready to serve requests.
func (*B) RecordEventAccess ¶
RecordEventAccess records an event access.
func (*B) RecordPayment ¶
RecordPayment records a payment.
func (*B) RemoveNIP43Member ¶
RemoveNIP43Member removes a NIP-43 member.
func (*B) SaveEvent ¶
SaveEvent saves an event to the database using the write batcher.
func (*B) SaveEventForImport ¶ added in v0.48.8
SaveEventForImport saves an event optimized for bulk import. It skips duplicate checking, deletion checking, and graph vertex creation to maximize import throughput. Use only for trusted data migration.
func (*B) SaveEventMinimal ¶ added in v0.48.8
SaveEventMinimal stores only the essential event data for fast bulk import. It skips all indexes - call BuildIndexes after import completes.
func (*B) SetLogLevel ¶
SetLogLevel changes the logging level.
func (*B) SetMarker ¶
SetMarker sets a metadata marker.
func (*B) SetRelayIdentitySecret ¶
SetRelayIdentitySecret sets the relay's identity secret key.
func (*B) StoreInviteCode ¶
StoreInviteCode stores an invite code.
func (*B) ValidateInviteCode ¶
ValidateInviteCode validates an invite code.
type BatchedWrite ¶
BatchedWrite represents a single write operation
type BatcherStats ¶
type BatcherStats struct {
TotalBatches uint64
TotalEvents uint64
TotalBytes uint64
AverageLatencyMs float64
LastFlushTime time.Time
LastFlushDuration time.Duration
}
BatcherStats contains batcher statistics
type BboltConfig ¶
type BboltConfig struct {
DataDir string
LogLevel string
// Batch settings (tuned for 7200rpm HDD)
BatchMaxEvents int // Max events before flush (default: 5000)
BatchMaxBytes int64 // Max bytes before flush (default: 128MB)
BatchFlushTimeout time.Duration // Max time before flush (default: 30s)
// Bloom filter settings
BloomSizeMB int // Bloom filter size in MB (default: 16)
// BBolt settings
NoSync bool // Disable fsync for performance (DANGEROUS)
InitialMmapSize int // Initial mmap size in bytes
}
BboltConfig holds bbolt-specific configuration
type BloomStats ¶
type BloomStats struct {
ApproxCount uint64 // Approximate number of elements
Cap uint // Capacity in bits
}
BloomStats contains bloom filter statistics.
type EdgeBloomFilter ¶
type EdgeBloomFilter struct {
// contains filtered or unexported fields
}
EdgeBloomFilter provides fast negative lookups for edge existence checks. Uses a bloom filter to avoid disk seeks when checking if an edge exists.
func NewEdgeBloomFilter ¶
func NewEdgeBloomFilter(sizeMB int, db *bolt.DB) (*EdgeBloomFilter, error)
NewEdgeBloomFilter creates or loads the edge bloom filter. sizeMB is the approximate size in megabytes. With 1% false positive rate, 16MB can hold ~10 million edges.
func (*EdgeBloomFilter) Add ¶
func (ebf *EdgeBloomFilter) Add(srcSerial, dstSerial uint64, edgeType byte)
Add adds an edge to the bloom filter. An edge is represented by source and destination serials plus edge type.
func (*EdgeBloomFilter) AddBatch ¶
func (ebf *EdgeBloomFilter) AddBatch(edges []EdgeKey)
AddBatch adds multiple edges to the bloom filter.
func (*EdgeBloomFilter) MayExist ¶
func (ebf *EdgeBloomFilter) MayExist(srcSerial, dstSerial uint64, edgeType byte) bool
MayExist checks if an edge might exist. Returns false if definitely doesn't exist (no disk access needed). Returns true if might exist (need to check disk to confirm).
func (*EdgeBloomFilter) Persist ¶
func (ebf *EdgeBloomFilter) Persist(db *bolt.DB) error
Persist saves the bloom filter to the database.
func (*EdgeBloomFilter) Stats ¶
func (ebf *EdgeBloomFilter) Stats() BloomStats
Stats returns bloom filter statistics.
type EdgeKey ¶
EdgeKey represents an edge for batch operations.
type EventBatch ¶
type EventBatch struct {
Serial uint64
EventData []byte // Serialized compact event data
Indexes []BatchedWrite // Index entries
EventVertex *EventVertex // Graph vertex for this event
PubkeyUpdate *PubkeyVertexUpdate // Update to author's pubkey vertex
MentionUpdates []*PubkeyVertexUpdate // Updates to mentioned pubkeys
EdgeKeys []EdgeKey // Edge keys for bloom filter
}
EventBatch represents a complete event with all its indexes and graph updates
type EventVertex ¶
type EventVertex struct {
AuthorSerial uint64 // Serial of the author pubkey
Kind uint16 // Event kind
PTagSerials []uint64 // Serials of pubkeys mentioned (p-tags)
ETagSerials []uint64 // Serials of events referenced (e-tags)
}
EventVertex stores the adjacency list for an event. Contains the author and all edges to other events/pubkeys.
func (*EventVertex) Decode ¶
func (ev *EventVertex) Decode(data []byte) error
Decode deserializes bytes into an EventVertex.
func (*EventVertex) Encode ¶
func (ev *EventVertex) Encode() []byte
Encode serializes the EventVertex to bytes. Format: author(5) | kind(2) | ptag_count(varint) | [ptag_serials(5)...] | etag_count(varint) | [etag_serials(5)...]
type Logger ¶
Logger wraps the lol logger for BBolt
func NewLogger ¶
NewLogger creates a new Logger instance
func (*Logger) Debugf ¶
Debugf logs a debug message
func (*Logger) Errorf ¶
Errorf logs an error message
func (*Logger) Infof ¶
Infof logs an info message
func (*Logger) SetLogLevel ¶
SetLogLevel updates the log level
func (*Logger) Tracef ¶
Tracef logs a trace message
type PubkeyVertex ¶
type PubkeyVertex struct {
AuthoredEvents []uint64 // Event serials this pubkey authored
MentionedIn []uint64 // Event serials that mention this pubkey (p-tags)
}
PubkeyVertex stores the adjacency list for a pubkey. Contains all events authored by or mentioning this pubkey.
func (*PubkeyVertex) AddAuthored ¶
func (pv *PubkeyVertex) AddAuthored(eventSerial uint64)
AddAuthored adds an event serial to the authored list if not already present.
func (*PubkeyVertex) AddMention ¶
func (pv *PubkeyVertex) AddMention(eventSerial uint64)
AddMention adds an event serial to the mentioned list if not already present.
func (*PubkeyVertex) Decode ¶
func (pv *PubkeyVertex) Decode(data []byte) error
Decode deserializes bytes into a PubkeyVertex.
func (*PubkeyVertex) Encode ¶
func (pv *PubkeyVertex) Encode() []byte
Encode serializes the PubkeyVertex to bytes. Format: authored_count(varint) | [serials(5)...] | mentioned_count(varint) | [serials(5)...]
func (*PubkeyVertex) HasAuthored ¶
func (pv *PubkeyVertex) HasAuthored(eventSerial uint64) bool
HasAuthored checks if the pubkey authored the given event.
func (*PubkeyVertex) IsMentionedIn ¶
func (pv *PubkeyVertex) IsMentionedIn(eventSerial uint64) bool
IsMentionedIn checks if the pubkey is mentioned in the given event.
func (*PubkeyVertex) RemoveAuthored ¶
func (pv *PubkeyVertex) RemoveAuthored(eventSerial uint64)
RemoveAuthored removes an event serial from the authored list.
func (*PubkeyVertex) RemoveMention ¶
func (pv *PubkeyVertex) RemoveMention(eventSerial uint64)
RemoveMention removes an event serial from the mentioned list.
type PubkeyVertexUpdate ¶
type PubkeyVertexUpdate struct {
PubkeySerial uint64
AddAuthored uint64 // Event serial to add to authored (0 if none)
AddMention uint64 // Event serial to add to mentions (0 if none)
}
PubkeyVertexUpdate represents an update to a pubkey's vertex
type WriteBatcher ¶
type WriteBatcher struct {
// contains filtered or unexported fields
}
WriteBatcher accumulates writes and flushes them in batches. Optimized for HDD with large batches and periodic flushes.
func NewWriteBatcher ¶
func NewWriteBatcher(db *bolt.DB, bloom *EdgeBloomFilter, cfg *BboltConfig, logger *Logger) *WriteBatcher
NewWriteBatcher creates a new write batcher
func (*WriteBatcher) Add ¶
func (wb *WriteBatcher) Add(batch *EventBatch) error
Add adds an event batch to the pending writes
func (*WriteBatcher) Flush ¶
func (wb *WriteBatcher) Flush() error
Flush writes all pending batches to BBolt
func (*WriteBatcher) PendingCount ¶
func (wb *WriteBatcher) PendingCount() int
PendingCount returns the number of pending events
func (*WriteBatcher) Shutdown ¶
func (wb *WriteBatcher) Shutdown() error
Shutdown gracefully shuts down the batcher
func (*WriteBatcher) Stats ¶
func (wb *WriteBatcher) Stats() BatcherStats
Stats returns current batcher statistics
Source Files
¶
- batcher.go
- bbolt.go
- bloom.go
- fetch-event.go
- get-serial-by-id.go
- graph.go
- helpers.go
- identity.go
- import-export.go
- import-minimal.go
- init.go
- logger.go
- markers.go
- query-graph.go
- save-event-bulk.go
- save-event.go
- serial.go
- stubs.go