store

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Part

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

Part contains information about a single file part and its parent transfer. Also contains cryptographic information needed to encrypt the part data.

func (*Part) GetEncryptedPart

func (p *Part) GetEncryptedPart(contentsSize int) (
	encryptedPart, mac []byte, fp format.Fingerprint, err error)

GetEncryptedPart gets the specified part, encrypts it, and returns the encrypted part along with its MAC and fingerprint. An error is returned if no fingerprints are available.

func (*Part) GetFileID

func (p *Part) GetFileID() ftCrypto.ID

GetFileID returns the ID of the file.

func (*Part) GetRecipient

func (p *Part) GetRecipient() *id.ID

GetRecipient returns the recipient of the file transfer.

func (*Part) GetStatus

func (p *Part) GetStatus() SentPartStatus

GetStatus returns the SentPartStatus of this part.

func (*Part) MarkReceived

func (p *Part) MarkReceived()

MarkReceived marks the part as received. This should be called after the part has been received.

func (*Part) MarkSent

func (p *Part) MarkSent()

MarkSent marks the part as sent. This should be called after the round the part is sent on succeeds.

func (*Part) PartNum

func (p *Part) PartNum() uint16

PartNum returns the index of this part.

func (*Part) String

func (p *Part) String() string

String returns a human-readable representation of a Part. Used for debugging.

type Received

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

Received contains a list of all received transfers.

func NewOrLoadReceived

func NewOrLoadReceived(
	disableKV bool, kv versioned.KV) (*Received, []ftCrypto.ID, error)

NewOrLoadReceived attempts to load a Received from storage. Or if none exist, then a new Received is returned. A list of file IDs for all incomplete receives is also returned.

func (*Received) AddTransfer

func (r *Received) AddTransfer(recipient *id.ID, key *ftCrypto.TransferKey,
	fid ftCrypto.ID, transferMAC []byte, fileSize uint32, numParts,
	numFps uint16) (*ReceivedTransfer, error)

AddTransfer adds the ReceivedTransfer to the map keyed on its file ID.

func (*Received) GetTransfer

func (r *Received) GetTransfer(fid ftCrypto.ID) (*ReceivedTransfer, bool)

GetTransfer returns the ReceivedTransfer with the provided file ID or false if none exists.

func (*Received) LoadTransfers

func (r *Received) LoadTransfers(
	fidList []ftCrypto.ID) ([]*ReceivedTransfer, error)

LoadTransfers loads all received transfers in the list from storage into Received It returns a list of all incomplete transfers so that their fingerprints can be re-added to the listener.

func (*Received) RemoveTransfer

func (r *Received) RemoveTransfer(fid ftCrypto.ID) error

RemoveTransfer removes the transfer from the map. If no transfer exists, returns nil. Only errors due to saving to storage are returned.

func (*Received) RemoveTransfers

func (r *Received) RemoveTransfers(fidList ...ftCrypto.ID) error

RemoveTransfers removes the transfers from the map.

type ReceivedTransfer

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

ReceivedTransfer contains information and progress data for a receiving or received file transfer.

func (*ReceivedTransfer) AddPart

func (rt *ReceivedTransfer) AddPart(part []byte, partNum int) error

AddPart adds the file part to the list of file parts at the index of partNum.

func (*ReceivedTransfer) CompareAndSwapCallbackFps

func (rt *ReceivedTransfer) CompareAndSwapCallbackFps(callbackID uint64,
	completed bool, received, total uint16, err error) bool

CompareAndSwapCallbackFps compares the fingerprint to the previous callback call's fingerprint. If they are different, the new one is stored, and it returns true. Returns false if they are the same.

func (*ReceivedTransfer) CopyPartStatusVector

func (rt *ReceivedTransfer) CopyPartStatusVector() *utility.StateVector

CopyPartStatusVector returns a copy of the part status vector that can be used to look up the current status of parts. Note that the statuses are from when this function is called and not realtime.

func (*ReceivedTransfer) Delete

func (rt *ReceivedTransfer) Delete() error

Delete deletes all data in the ReceivedTransfer from storage.

func (*ReceivedTransfer) GetFile

func (rt *ReceivedTransfer) GetFile() []byte

GetFile concatenates all file parts and returns it as a single complete file. Note that this function does not care for the completeness of the file and returns all parts it has.

func (*ReceivedTransfer) GetFileID

func (rt *ReceivedTransfer) GetFileID() ftCrypto.ID

GetFileID returns the file's ID.

func (*ReceivedTransfer) GetFileSize

func (rt *ReceivedTransfer) GetFileSize() uint32

GetFileSize returns the size of the entire file transfer.

func (*ReceivedTransfer) GetNewCallbackID

func (rt *ReceivedTransfer) GetNewCallbackID() uint64

GetNewCallbackID issues a new unique for a callback.

func (*ReceivedTransfer) GetNumParts

func (rt *ReceivedTransfer) GetNumParts() uint16

GetNumParts returns the total number of file parts in the transfer.

func (*ReceivedTransfer) GetRecipient

func (rt *ReceivedTransfer) GetRecipient() *id.ID

GetRecipient returns the transfer's recipient ID.

func (*ReceivedTransfer) GetUnusedCyphers

func (rt *ReceivedTransfer) GetUnusedCyphers() []cypher.Cypher

GetUnusedCyphers returns a list of cyphers with unused fingerprint numbers.

func (*ReceivedTransfer) NumReceived

func (rt *ReceivedTransfer) NumReceived() uint16

NumReceived returns the number of parts that have been received.

type Sent

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

Sent contains a list of all sent transfers.

func NewOrLoadSent

func NewOrLoadSent(kv versioned.KV) (*Sent, []ftCrypto.ID, error)

NewOrLoadSent attempts to load Sent from storage. Or if none exist, then a new Sent is returned. A list of file IDs for all incomplete sends is also returned.

func (*Sent) AddTransfer

func (s *Sent) AddTransfer(recipient *id.ID, sentTimestamp time.Time,
	key *ftCrypto.TransferKey, mac []byte, fid ftCrypto.ID, fileSize uint32,
	parts [][]byte, numFps uint16, retry float32) (*SentTransfer, error)

AddTransfer creates a SentTransfer and adds it to the map keyed on its file ID.

func (*Sent) GetTransfer

func (s *Sent) GetTransfer(fid ftCrypto.ID) (*SentTransfer, bool)

GetTransfer returns the SentTransfer with the given file ID or false if none exists.

func (*Sent) LoadTransfer

func (s *Sent) LoadTransfer(
	fid ftCrypto.ID, parts [][]byte) (*SentTransfer, error)

LoadTransfer loads the sent transfer with the file ID from storage into Sent and returns it.

func (*Sent) RemoveTransfer

func (s *Sent) RemoveTransfer(fid ftCrypto.ID) error

RemoveTransfer removes the transfer from the map. If no transfer exists, returns nil. Only errors due to saving to storage are returned.

func (*Sent) RemoveTransfers

func (s *Sent) RemoveTransfers(fidList ...ftCrypto.ID) error

RemoveTransfers removes the transfers from the map.

type SentPartStatus

type SentPartStatus uint8

SentPartStatus represents the current status of an individual sent file part.

const (
	// UnsentPart is the status when a part has not been sent yet.
	UnsentPart SentPartStatus = iota

	// SentPart is the status when a part has been sent and hte round has
	// successfully completed, but the recipient has yet to receive it.
	SentPart

	// ReceivedPart is the status when a part has been sent and received.
	ReceivedPart
)

func (SentPartStatus) String

func (sps SentPartStatus) String() string

String returns a human-readable form of SentPartStatus for debugging and logging. This function adheres to the fmt.Stringer interface.

type SentTransfer

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

SentTransfer contains information and progress data for sending or sent file transfer.

func (*SentTransfer) CompareAndSwapCallbackFps

func (st *SentTransfer) CompareAndSwapCallbackFps(callbackID uint64,
	completed bool, sent, received, total uint16, err error) bool

CompareAndSwapCallbackFps compares the fingerprint to the previous callback call's fingerprint. If they are different, the new one is stored, and it returns true. Returns fall if they are the same.

func (*SentTransfer) CopyPartStatusVector

func (st *SentTransfer) CopyPartStatusVector() *utility.MultiStateVector

CopyPartStatusVector returns a copy of the part status vector that can be used to look up the current status of parts. Note that the statuses are from when this function is called and not realtime.

func (*SentTransfer) Delete

func (st *SentTransfer) Delete() error

Delete deletes all data in the SentTransfer from storage.

func (*SentTransfer) GetFileID

func (st *SentTransfer) GetFileID() ftCrypto.ID

GetFileID returns the file's ID.

func (*SentTransfer) GetFileSize

func (st *SentTransfer) GetFileSize() uint32

GetFileSize returns the size of the entire file transfer.

func (*SentTransfer) GetKey

func (st *SentTransfer) GetKey() *ftCrypto.TransferKey

GetKey returns the transfer key used for encrypting/decrypting.

func (*SentTransfer) GetMAC

func (st *SentTransfer) GetMAC() []byte

GetMAC returns the transfer MAC used to verify the file.

func (*SentTransfer) GetNewCallbackID

func (st *SentTransfer) GetNewCallbackID() uint64

GetNewCallbackID issues a new unique for a callback.

func (*SentTransfer) GetNumParts

func (st *SentTransfer) GetNumParts() uint16

GetNumParts returns the total number of file parts in the transfer.

func (*SentTransfer) GetRecipient

func (st *SentTransfer) GetRecipient() *id.ID

GetRecipient returns the transfer's recipient ID.

func (*SentTransfer) GetRetry

func (st *SentTransfer) GetRetry() float32

GetRetry returns the retry number.

func (*SentTransfer) GetSentParts

func (st *SentTransfer) GetSentParts() []*Part

GetSentParts builds a list of all sent parts, each in a Part object.

func (*SentTransfer) GetUnsentParts

func (st *SentTransfer) GetUnsentParts() []*Part

GetUnsentParts builds a list of all unsent parts, each in a Part object.

func (*SentTransfer) NumReceived

func (st *SentTransfer) NumReceived() uint16

NumReceived returns the number of parts that have been received.

func (*SentTransfer) NumSent

func (st *SentTransfer) NumSent() uint16

NumSent returns the number of parts that have been sent.

func (*SentTransfer) SentTimestamp

func (st *SentTransfer) SentTimestamp() time.Time

SentTimestamp returns the time when the file was first queued to send.

func (*SentTransfer) Status

func (st *SentTransfer) Status() TransferStatus

Status returns the status of the transfer.

type TransferStatus

type TransferStatus int

TransferStatus indicates the state of the transfer.

const (
	// Running indicates that the transfer is in the processes of sending
	Running TransferStatus = iota

	// Completed indicates that all file parts have been sent and arrived
	Completed

	// Failed indicates that the transfer has run out of sending retries
	Failed
)

func (TransferStatus) String

func (ts TransferStatus) String() string

String prints the string representation of the TransferStatus. This function satisfies the fmt.Stringer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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