Documentation
¶
Index ¶
- Variables
- type CheckpointModel
- type CheckpointSubtreeModel
- type Impl
- func (i *Impl) AddMirrorSignature(ctx context.Context, id int64, mirrorID string, mirrorCosig []byte, ...) error
- func (i *Impl) AddSubtreeMirrorSignature(ctx context.Context, id int64, mirrorID string, mirrorSignature []byte, ...) error
- func (i *Impl) GetCheckpointSubtree(ctx context.Context, mtcLogID string, id int64) (*CheckpointSubtreeModel, error)
- func (i *Impl) GetUnsignedSubtrees(ctx context.Context, mtcLogID string, maxEnd uint64, limit int) ([]*CheckpointSubtreeModel, error)
- func (i *Impl) InsertCheckpoint(ctx context.Context, c *CheckpointModel) error
- func (i *Impl) InsertCheckpointSubtree(ctx context.Context, model *CheckpointSubtreeModel) (int64, error)
- func (i *Impl) LatestCheckpoint(ctx context.Context, mtcLogID string) (*CheckpointModel, error)
- func (i *Impl) WithTransaction(ctx context.Context, f TxFunc) (any, error)
- type Tx
- type TxFunc
Constants ¶
This section is empty.
Variables ¶
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 (*Impl) AddSubtreeMirrorSignature ¶ added in v0.20261027.0
func (*Impl) GetCheckpointSubtree ¶ added in v0.20261006.0
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 ¶
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.