sqlite

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrHeadMismatch = errors.New("head mismatch")
)

Functions

This section is empty.

Types

type LogRecord

type LogRecord struct {
	LogDID    string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type LogStore

type LogStore struct {
	// contains filtered or unexported fields
}

func OpenLogStore

func OpenLogStore(basePath, logDID string) (*LogStore, error)

func (*LogStore) AddRevocation

func (s *LogStore) AddRevocation(ctx context.Context, delegationCID string) error

AddRevocation marks a delegation as revoked. Idempotent.

func (*LogStore) Close

func (s *LogStore) Close() error

func (*LogStore) CreateLogRecord

func (s *LogStore) CreateLogRecord(ctx context.Context, logDID string) error

func (*LogStore) DBPath

func (s *LogStore) DBPath() string

func (*LogStore) DequeuePendingCARs

func (s *LogStore) DequeuePendingCARs(ctx context.Context, limit int) ([]storage.PendingCAR, error)

DequeuePendingCARs atomically claims up to `limit` pending upload_queue entries (transitioning them from 'pending' to 'uploading') and returns them. Items in 'uploading' state are invisible to other workers.

func (*LogStore) EnqueueAndUpdateHead

func (s *LogStore) EnqueueAndUpdateHead(ctx context.Context, logDID string, treeSize uint64, headCID string, carData []byte, blobs []storage.PendingBlob) (int64, error)

EnqueueAndUpdateHead atomically updates latest_head_car and inserts an upload_queue row. Returns the new queue entry ID.

func (*LogStore) GetHead

func (s *LogStore) GetHead(ctx context.Context, logDID string) (string, uint64, error)

GetHead returns the current head CID and tree size for a log. Reads from latest_head_car, which is updated synchronously on every append. Returns ("", 0, nil) if no record exists yet (log has never had an entry appended). Implements storage.StateStore interface.

func (*LogStore) GetLatestHeadCAR

func (s *LogStore) GetLatestHeadCAR(ctx context.Context, logDID string) (headCID string, treeSize uint64, carData []byte, err error)

GetLatestHeadCAR retrieves the latest full-state CAR for a log. Returns ("", 0, nil, nil) if no record exists.

func (*LogStore) GetLogRecord

func (s *LogStore) GetLogRecord(ctx context.Context, logDID string) (*LogRecord, error)

func (*LogStore) GetPendingBlobsForCAR

func (s *LogStore) GetPendingBlobsForCAR(ctx context.Context, queueID int64) ([]storage.PendingBlob, error)

GetPendingBlobsForCAR returns pending blobs for a given queue entry.

func (*LogStore) GetRevocations

func (s *LogStore) GetRevocations(ctx context.Context) ([]string, error)

GetRevocations returns all revoked delegation CIDs.

func (*LogStore) GetTreeState

func (s *LogStore) GetTreeState(ctx context.Context, logDID string) (size uint64, root []byte, err error)

GetTreeState retrieves the Merkle tree state for a log. Returns (0, nil, nil) if no tree state exists yet.

func (*LogStore) IsRevoked

func (s *LogStore) IsRevoked(ctx context.Context, delegationCID string) (bool, error)

IsRevoked checks if a delegation has been revoked.

func (*LogStore) ListLogDIDs

func (s *LogStore) ListLogDIDs(ctx context.Context) ([]string, error)

ListLogDIDs returns all log DIDs stored in this database.

func (*LogStore) LogDID

func (s *LogStore) LogDID() string

func (*LogStore) MarkBlobFailed

func (s *LogStore) MarkBlobFailed(ctx context.Context, id int64, errMsg string) error

MarkBlobFailed records a blob upload error.

func (*LogStore) MarkBlobUploaded

func (s *LogStore) MarkBlobUploaded(ctx context.Context, id int64) error

MarkBlobUploaded marks a blob as uploaded and nulls blob_data.

func (*LogStore) MarkCARFailed

func (s *LogStore) MarkCARFailed(ctx context.Context, id int64, errMsg string) error

MarkCARFailed increments retry_count and records the error.

func (*LogStore) MarkCARUploaded

func (s *LogStore) MarkCARUploaded(ctx context.Context, id int64) error

MarkCARUploaded marks a queue entry as uploaded and nulls car_data.

func (*LogStore) SetLatestHeadCAR

func (s *LogStore) SetLatestHeadCAR(ctx context.Context, logDID string, treeSize uint64, headCID string, carData []byte) error

SetLatestHeadCAR upserts the latest full-state CAR for a log.

func (*LogStore) SetTreeState

func (s *LogStore) SetTreeState(ctx context.Context, logDID string, size uint64, root []byte) error

SetTreeState sets the Merkle tree state for a log (upsert).

type StoreManager

type StoreManager struct {
	// contains filtered or unexported fields
}

StoreManager manages multiple LogStore instances with caching.

func NewStoreManager

func NewStoreManager(basePath string) *StoreManager

NewStoreManager creates a new StoreManager.

func (*StoreManager) BasePath

func (m *StoreManager) BasePath() string

BasePath returns the base path for log storage.

func (*StoreManager) CloseAll

func (m *StoreManager) CloseAll() error

CloseAll closes all cached stores.

func (*StoreManager) GetStateStore

func (m *StoreManager) GetStateStore(logDID string) (storage.StateStore, error)

GetStateStore returns the StateStore for the given log DID. This is a convenience method that returns storage.StateStore interface.

func (*StoreManager) GetStore

func (m *StoreManager) GetStore(logDID string) (*LogStore, error)

GetStore returns the LogStore for the given log DID. If logDID ends with "-revocations", it returns the store for the main log. Stores are cached and reused.

func (*StoreManager) ListLogDIDs

func (m *StoreManager) ListLogDIDs() ([]string, error)

ListLogDIDs returns the DIDs of all known logs by enumerating subdirectories.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL