psdb

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgreementStatusUnsent sets the agreement status to UNSENT
	AgreementStatusUnsent = iota
	// AgreementStatusSent  sets the agreement status to SENT
	AgreementStatusSent
	// AgreementStatusReject sets the agreement status to REJECT
	AgreementStatusReject
)

Variables

View Source
var (
	// Error is the default psdb errs class
	Error = errs.Class("psdb")
)

Functions

This section is empty.

Types

type Agreement

type Agreement struct {
	Agreement pb.Order
	Signature []byte
}

Agreement is a struct that contains a bandwidth agreement and the associated signature

type AgreementStatus

type AgreementStatus int32

AgreementStatus keep tracks of the agreement payout status

type DB

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

DB is a piece store database

func Open

func Open(DBPath string) (db *DB, err error)

Open opens DB at DBPath

func OpenInMemory

func OpenInMemory() (db *DB, err error)

OpenInMemory opens sqlite DB inmemory

func (*DB) AddTTL

func (db *DB) AddTTL(id string, expiration, size int64) error

AddTTL adds TTL into database by id

func (*DB) Begin

func (db *DB) Begin() (*sql.Tx, error)

Begin begins transaction

func (*DB) Close

func (db *DB) Close() error

Close the database

func (*DB) DeleteBandwidthAllocationBySerialnum

func (db *DB) DeleteBandwidthAllocationBySerialnum(serialnum string) error

DeleteBandwidthAllocationBySerialnum finds an allocation by signature and deletes it

func (*DB) DeleteBandwidthAllocationPayouts

func (db *DB) DeleteBandwidthAllocationPayouts() error

DeleteBandwidthAllocationPayouts delete paid and/or old payout enteries based on days old

func (*DB) DeleteObsolete added in v0.9.0

func (db *DB) DeleteObsolete(path string) (err error)

DeleteObsolete deletes obsolete pieces

func (*DB) DeleteTTLByID

func (db *DB) DeleteTTLByID(id string) error

DeleteTTLByID finds the TTL in the database by id and delete it

func (*DB) GetBandwidthAllocationBySignature

func (db *DB) GetBandwidthAllocationBySignature(signature []byte) ([]*pb.Order, error)

GetBandwidthAllocationBySignature finds allocation info by signature

func (*DB) GetBandwidthAllocations

func (db *DB) GetBandwidthAllocations() (map[storj.NodeID][]*Agreement, error)

GetBandwidthAllocations all bandwidth agreements

func (*DB) GetBandwidthUsedByDay

func (db *DB) GetBandwidthUsedByDay(t time.Time) (size int64, err error)

GetBandwidthUsedByDay finds the so far bw used by day and return it

func (*DB) GetBwaStatusBySerialNum

func (db *DB) GetBwaStatusBySerialNum(serialnum string) (status AgreementStatus, err error)

GetBwaStatusBySerialNum get BWA status by serial num

func (*DB) GetTTLByID

func (db *DB) GetTTLByID(id string) (expiration int64, err error)

GetTTLByID finds the TTL in the database by id and return it

func (*DB) GetTotalBandwidthBetween

func (db *DB) GetTotalBandwidthBetween(startdate time.Time, enddate time.Time) (int64, error)

GetTotalBandwidthBetween each row in the bwusagetbl contains the total bw used per day

func (*DB) Migration

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

Migration define piecestore DB migration

func (*DB) RawDB

func (db *DB) RawDB() *sql.DB

RawDB returns access to the raw database, only for migration tests.

func (*DB) Rebind

func (db *DB) Rebind(s string) string

Rebind rebind parameters

func (*DB) Schema

func (db *DB) Schema() string

Schema returns schema

func (*DB) SumTTLSizes

func (db *DB) SumTTLSizes() (int64, error)

SumTTLSizes sums the size column on the ttl table

func (*DB) UpdateBandwidthAllocationStatus

func (db *DB) UpdateBandwidthAllocationStatus(serialnum string, status AgreementStatus) (err error)

UpdateBandwidthAllocationStatus update the bwa payout status

func (*DB) WriteBandwidthAllocToDB

func (db *DB) WriteBandwidthAllocToDB(rba *pb.Order) error

WriteBandwidthAllocToDB inserts bandwidth agreement into DB

Jump to

Keyboard shortcuts

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