Documentation ¶
Overview ¶
Package database implements a checksum database backed by an underlying transactional key-value store.
Index ¶
- type DB
- func (db *DB) Add(ctx context.Context, records []NewRecord) error
- func (db *DB) Config(ctx context.Context, key string) (string, error)
- func (db *DB) Lookup(ctx context.Context, key string) (int64, error)
- func (db *DB) NumRecords(ctx context.Context) (int64, error)
- func (db *DB) ProveRecord(ctx context.Context, t, n int64) (tlog.RecordProof, error)
- func (db *DB) ProveTree(ctx context.Context, t, n int64) (tlog.TreeProof, error)
- func (db *DB) ReadHashes(ctx context.Context, indexes []int64) ([]tlog.Hash, error)
- func (db *DB) ReadRecords(ctx context.Context, id, n int64) ([][]byte, error)
- func (db *DB) ReadTileData(ctx context.Context, t tlog.Tile) ([]byte, error)
- func (db *DB) SetConfig(ctx context.Context, key, value string) error
- func (db *DB) TreeHash(ctx context.Context, n int64) (tlog.Hash, error)
- type NewRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
A DB is a Go checksum database.
func (*DB) Add ¶
Add adds a new record with the given content and associated key. It returns the record id for the new record. If the key is the empty string, the new record has no key.
If a record already exists with the same content and key, Add returns the record id for the existing record instead of adding a new one.
If a record already exists with the same content but a different key, or the same key but different content, Add returns an error.
func (*DB) Lookup ¶
Lookup looks up a record by its associated key ("module@version"), returning the record ID.
func (*DB) NumRecords ¶
NumRecords returns the number of records in the database.
func (*DB) ProveRecord ¶
ProveRecord returns the proof that the tree of size t contains the record with index n.
func (*DB) ProveTree ¶
ProveTree returns the proof that the tree of size t contains as a prefix all the records from the tree of smaller size n.
func (*DB) ReadHashes ¶
ReadHashes reads and returns the hashes with the given storage indexes.
func (*DB) ReadRecords ¶
ReadRecords returns the content for the n records starting at id.
func (*DB) ReadTileData ¶
ReadTileData reads the hashes for the tile t and returns the corresponding tile data.
type NewRecord ¶
type NewRecord struct { Key string // record key ("module@version") Content []byte // record content ID int64 // record log ID sequence number Err error // error inserting record, if any }
A NewRecord tracks a new record to be added to the database. The caller initializes Key and Content, and Add sets ID and Err.