pindb

package
v0.0.0-...-a092f05 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPinDB = errs.Class("PinDB")

ErrPinDB indicates about internal wallets DB error.

View Source
var (

	// Error is the default easypindb errs class.
	Error = errs.Class("easypindb")
)

Functions

func TestRun

func TestRun(t *testing.T, test func(ctx *testcontext.Context, t *testing.T, db *DB))

TestRun creates new storjscan test database, create tables and execute test function against that db.

Types

type Cid

type Cid struct {
	Hash      string
	Pinned    time.Time
	ValidDays uint
}

type DB

type DB struct {
	*dbx.DB
	// contains filtered or unexported fields
}

DB is easypindb database.

func Open

func Open(ctx context.Context, log *zap.Logger, databaseURL string) (*DB, error)

Open creates instance of storjscan DB.

func (*DB) MigrateToLatest

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

MigrateToLatest migrates pindb to the latest version.

func (*DB) Pins

func (db *DB) Pins() *PinDB

Pins creates new PinDB with current DB connection.

func (*DB) PostgresMigration

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

PostgresMigration returns steps needed for migrating postgres database.

type Pin

type Pin struct {
	Cid         string
	Amount      *big.Int
	Transaction string
	LogIndex    uint
	Processed   bool
	Error       string
}

Pin represents an entry in the pin table.

type PinDB

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

PinDB is database stores the pinning events.

architecture: Database

func (*PinDB) AllNodes

func (p *PinDB) AllNodes(ctx context.Context) ([]Cid, error)

func (*PinDB) AllPins

func (p *PinDB) AllPins(ctx context.Context) ([]Pin, error)

func (*PinDB) Create

func (p *PinDB) Create(ctx context.Context, tx string, ix uint, cid string, amount *big.Int) error

Create inserts a new entry in the wallets table.

func (*PinDB) CreateNode

func (p *PinDB) CreateNode(ctx context.Context, txHash string, ix int, cid string, days uint) (err error)

CreateNode inserts node record to the table (represents a pinned resource).

func (*PinDB) FindNew

func (p *PinDB) FindNew(ctx context.Context) ([]Pin, error)

func (*PinDB) Node

func (p *PinDB) Node(ctx context.Context, hash string) (Cid, error)

func (*PinDB) PinsOfHash

func (p *PinDB) PinsOfHash(ctx context.Context, cid string) ([]Pin, error)

func (*PinDB) RecordError

func (p *PinDB) RecordError(ctx context.Context, transaction string, index uint, cid string, s string) error

type TestDB

type TestDB struct {
	*DB
	// contains filtered or unexported fields
}

TestDB is test storjscan database with unique schema which performs cleanup on close.

func OpenDB

func OpenDB(ctx context.Context, log *zap.Logger, connStr, testName, category string) (*TestDB, error)

OpenDB opens new unique temp storjscan test database.

func (*TestDB) Close

func (db *TestDB) Close() error

Close closes test database and performs cleanup.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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