treedb

package
v0.20261027.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIssuanceLogNotInitialized = errors.New("issuance log DB not initialized")

Functions

This section is empty.

Types

type CheckpointModel

type CheckpointModel struct {
	ID              int64   `db:"id"`
	MTCLogID        string  `db:"mtcLogID"`
	MTCASignature   []byte  `db:"mtcaSignature"`
	MirrorID        *string `db:"mirrorID"`
	MirrorSignature []byte  `db:"mirrorSignature"`
	TreeSize        int64   `db:"treeSize"`
	RootHash        []byte  `db:"rootHash"`
}

CheckpointModel represents the database storage of a checkpoint and associated signatures.

For signing, the TreeSize and RootHash fields are incorporated into a `cosigned.Message`.

func (*CheckpointModel) Mirrored

func (c *CheckpointModel) Mirrored() bool

func (*CheckpointModel) Valid

func (c *CheckpointModel) Valid() error

type CheckpointSubtreeModel added in v0.20261006.0

type CheckpointSubtreeModel struct {
	ID              int64   `db:"id"`
	MTCLogID        string  `db:"mtcLogID"`
	MTCASignature   []byte  `db:"mtcaSignature"`
	MirrorID        *string `db:"mirrorID"`
	MirrorSignature []byte  `db:"mirrorSignature"`
	SubtreeStart    uint64  `db:"subtreeStart"`
	SubtreeEnd      uint64  `db:"subtreeEnd"`
	SubtreeHash     []byte  `db:"subtreeHash"`
}

func (*CheckpointSubtreeModel) Mirrored added in v0.20261006.0

func (s *CheckpointSubtreeModel) Mirrored() bool

func (*CheckpointSubtreeModel) Valid added in v0.20261006.0

func (s *CheckpointSubtreeModel) Valid() error

type Impl

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

func New

func New(dbMap *db.WrappedMap) *Impl

New returns an `*Impl` object that uses the given *db.WrappedMap. As a side effect, it registers table mappings with borp.

func (*Impl) AddMirrorSignature

func (i *Impl) AddMirrorSignature(ctx context.Context, id int64, mirrorID string, mirrorCosig []byte, mtcLogID string) error

func (*Impl) AddSubtreeMirrorSignature added in v0.20261027.0

func (i *Impl) AddSubtreeMirrorSignature(ctx context.Context, id int64, mirrorID string, mirrorSignature []byte, mtcLogID string) error

func (*Impl) GetCheckpointSubtree added in v0.20261006.0

func (i *Impl) GetCheckpointSubtree(ctx context.Context, mtcLogID string, id int64) (*CheckpointSubtreeModel, error)

func (*Impl) GetUnsignedSubtrees added in v0.20261027.0

func (i *Impl) GetUnsignedSubtrees(ctx context.Context, mtcLogID string, maxEnd uint64, limit int) ([]*CheckpointSubtreeModel, error)

GetUnsignedSubtrees returns up to limit of the log's newest subtrees that end at or before maxEnd and lack a mirror signature.

func (*Impl) InsertCheckpoint added in v0.20261006.0

func (i *Impl) InsertCheckpoint(ctx context.Context, c *CheckpointModel) error

InsertCheckpoint inserts the given CheckpointModel into the database.

It modifies its parameter's ID field to set the newly allocated autoincrement ID.

func (*Impl) InsertCheckpointSubtree added in v0.20261006.0

func (i *Impl) InsertCheckpointSubtree(ctx context.Context, model *CheckpointSubtreeModel) (int64, error)

InsertCheckpointSubtree inserts a row into db, and returns the inserted row ID, or an error. Because borp's `Insert` modifies its argument to set the ID when a field is marked as autoincrement (`.SetKeys(true, "ID")`), this method also modifies its argument (in this case, `model`).

func (*Impl) LatestCheckpoint

func (i *Impl) LatestCheckpoint(ctx context.Context, mtcLogID string) (*CheckpointModel, error)

func (*Impl) WithTransaction added in v0.20261006.0

func (i *Impl) WithTransaction(ctx context.Context, f TxFunc) (any, error)

WithTransaction calls `github.com/letsencrypt/boulder/db.WithTransaction` for the given transaction function, with the built-in DB.

type Tx added in v0.20261020.0

type Tx interface {
	AlreadyInitialized(ctx context.Context, mtcLogID string) (bool, error)
	InsertFirstCheckpoint(ctx context.Context, firstCheckpoint *CheckpointModel) error
	AddMTCASignature(ctx context.Context, id int64, caSig []byte, mtcLogID string) error
	SelectLatestForUpdate(ctx context.Context, mtcLogID string) (int64, error)
	SetLatestCheckpointID(ctx context.Context, mtcLogID string, oldID, newID int64) error
}

Tx represents a transaction.

The methods on this are those that are currently called within a transaction by the MTCA. We don't include these methods on `*Impl` because we don't want them to be called outside a transaction. We don't include all the methods of `*Impl` here because any test that wants to mock `Impl.WithTransaction` needs to implement a `Tx`, which means such a test needs to implement each method in this interface. That means keeping it small is useful.

type TxFunc added in v0.20261020.0

type TxFunc func(tx Tx) (any, error)

TxFunc is a function that gets run in a transaction by `Impl.WithTransaction` (or mocks).

Jump to

Keyboard shortcuts

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