db

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 20 Imported by: 2

Documentation

Overview

Copyright (C) 2022 Storj Labs, Inc. See LICENSE for copying information.

Copyright (C) 2022 Storj Labs, Inc. See LICENSE for copying information.

Copyright (C) 2022 Storj Labs, Inc. See LICENSE for copying information.

Copyright (C) 2022 Storj Labs, Inc. See LICENSE for copying information.

Index

Constants

View Source
const (
	UnpackedStatus = 0
	PackingStatus  = 1
	PackedStatus   = 2
)

Variables

View Source
var Error = errs.Class("db")

Error is the error class for datastore database.

Functions

This section is empty.

Types

type Block

type Block struct {
	CID        string
	Size       int
	Data       []byte
	Deleted    bool
	PackStatus int
	PackObject string
	PackOffset int
}

type DB

type DB struct {
	tagsql.DB
}

DB is the datastore database for mapping IPFS blocks to Storj object packs.

func Open

func Open(ctx context.Context, databaseURL string) (db *DB, err error)

Open creates instance of the database.

func Wrap

func Wrap(db tagsql.DB) *DB

Wrap turns a tagsql.DB into a DB struct.

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, key ds.Key) (err error)

func (*DB) DeleteBlock

func (db *DB) DeleteBlock(ctx context.Context, cid string) (err error)

func (*DB) Get

func (db *DB) Get(ctx context.Context, key ds.Key) (data []byte, err error)

func (*DB) GetBlock

func (db *DB) GetBlock(ctx context.Context, cid string) (block *Block, err error)

func (*DB) GetBlockSize

func (db *DB) GetBlockSize(ctx context.Context, cid string) (size int, err error)

func (*DB) GetCreatedTime

func (db *DB) GetCreatedTime(ctx context.Context) (created time.Time, err error)

GetCreatedTime returns the time when the database was created.

func (*DB) GetNotPackedBlocksTotalSize

func (db *DB) GetNotPackedBlocksTotalSize(ctx context.Context) (unpackedSize, packingSize int64, err error)

func (*DB) GetSize

func (db *DB) GetSize(ctx context.Context, key ds.Key) (size int, err error)

func (*DB) GetUnpackedBlocksUpToMaxSize

func (db *DB) GetUnpackedBlocksUpToMaxSize(ctx context.Context, maxSize int) (cids []string, err error)

func (*DB) Has

func (db *DB) Has(ctx context.Context, key ds.Key) (exists bool, err error)

func (*DB) HasBlock

func (db *DB) HasBlock(ctx context.Context, cid string) (exists bool, err error)

func (*DB) MigrateToLatest

func (db *DB) MigrateToLatest(ctx context.Context) (err error)

MigrateToLatest migrates pindb to the latest version.

func (*DB) Migration

func (db *DB) Migration() *migrate.Migration

Migration returns steps needed for migrating the database.

func (*DB) Put

func (db *DB) Put(ctx context.Context, key ds.Key, value []byte) (err error)

func (*DB) PutBlock

func (db *DB) PutBlock(ctx context.Context, cid string, value []byte) (err error)

func (*DB) QueryDatastore

func (db *DB) QueryDatastore(ctx context.Context, q dsq.Query) (result dsq.Results, err error)

func (*DB) QueryPackingBlocksData

func (db *DB) QueryPackingBlocksData(ctx context.Context, maxSize, maxBlocks int, result map[string][]byte) (err error)

func (*DB) QueryUnpackedBlocksData

func (db *DB) QueryUnpackedBlocksData(ctx context.Context, cids []string, result map[string][]byte) (err error)

func (*DB) TestingDeleteAll

func (db *DB) TestingDeleteAll(ctx context.Context) (err error)

TestingDeleteAll deletes all data from the database.

func (*DB) TestingUpdateBlockPackStatus

func (db *DB) TestingUpdateBlockPackStatus(ctx context.Context, cid string, newStatus int) (err error)

TestingUpdateBlockPackStatus updates the block pack status.

func (*DB) UpdatePackedBlocks

func (db *DB) UpdatePackedBlocks(ctx context.Context, packObjectKey string, cidOffs map[string]int) (err error)

Jump to

Keyboard shortcuts

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