db

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQL

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

SQL implements the DB interface

func (*SQL) AddBlob

func (s *SQL) AddBlob(hash string, length int, isStored bool) error

AddBlob adds a blob to the database.

func (*SQL) AddSDBlob

func (s *SQL) AddSDBlob(sdHash string, sdBlobLength int, sdBlob SdBlob) error

AddSDBlob takes the SD Hash number of blobs and the set of blobs. In a single db tx it inserts the sdblob information into a stream, and inserts the associated blobs' information in the database. If a blob fails the transaction is rolled back and error(s) are returned.

func (*SQL) Connect

func (s *SQL) Connect(dsn string) error

Connect will create a connection to the database

func (*SQL) GetHashRange

func (s *SQL) GetHashRange() (string, string, error)

GetHashRange gets the smallest and biggest hashes in the db

func (*SQL) GetStoredHashesInRange

func (s *SQL) GetStoredHashesInRange(ctx context.Context, start, end bits.Bitmap) (ch chan bits.Bitmap, ech chan error)

GetStoredHashesInRange gets stored blobs with hashes in a given range, and sends the hashes into a channel

func (*SQL) HasBlob

func (s *SQL) HasBlob(hash string) (bool, error)

HasBlob checks if the database contains the blob information.

func (*SQL) HasBlobs

func (s *SQL) HasBlobs(hashes []string) (map[string]bool, error)

HasBlobs checks if the database contains the set of blobs and returns a bool map.

func (*SQL) MissingBlobsForKnownStream added in v1.0.3

func (s *SQL) MissingBlobsForKnownStream(sdHash string) ([]string, error)

MissingBlobsForKnownStream returns missing blobs for an existing stream WARNING: if the stream does NOT exist, no blob hashes will be returned, which looks like no blobs are missing

type SdBlob added in v0.1.2

type SdBlob struct {
	StreamName string `json:"stream_name"`
	Blobs      []struct {
		Length   int    `json:"length"`
		BlobNum  int    `json:"blob_num"`
		BlobHash string `json:"blob_hash,omitempty"`
		Iv       string `json:"iv"`
	} `json:"blobs"`
	StreamType        string `json:"stream_type"`
	Key               string `json:"key"`
	SuggestedFileName string `json:"suggested_file_name"`
	StreamHash        string `json:"stream_hash"`
}

SdBlob is a special blob that contains information on the rest of the blobs in the stream

Jump to

Keyboard shortcuts

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