Documentation ¶
Index ¶
- type BytesTransferStats
- type ContextFileDownloadData
- type FileDecryptionStatus
- type FileInfo
- type Interface
- type Store
- func (c *Store) CancelContractFileDownloadContexts(key string) error
- func (c *Store) ClearPausedFileDownload(contractHash string, fileHash []byte)
- func (c *Store) CreateContract(contract *messages.DownloadContractProto) error
- func (c *Store) Debug(w http.ResponseWriter, r *http.Request)
- func (c *Store) DeleteContract(contractHash string) error
- func (c *Store) GetContract(contractHash string) (*messages.DownloadContractProto, error)
- func (c *Store) GetContractFileInfo(contractHash string, fileHash []byte) (FileInfo, error)
- func (c *Store) GetContractFiles(contractHash string) ([]FileInfo, error)
- func (c *Store) GetDownoadedFilePartInfos(contractHash string, fileHash []byte) []BytesTransferStats
- func (c *Store) GetReleaseContractFeesStatus(contractHash string) bool
- func (c *Store) GetTransferredBytes(contractHash string, fileHash []byte) uint64
- func (c *Store) IncrementTransferredBytes(contractHash string, fileHash []byte, fileNamePart, destinationFilePath string, ...)
- func (c *Store) IsPausedFileDownload(contractHash string, fileHash []byte) bool
- func (c *Store) LoadFromDB() error
- func (c *Store) PauseContractFileDownload(contractHash string, fileHash []byte)
- func (c *Store) PurgeInactiveContracts(purgeAfterSeconds int64) error
- func (c *Store) ReleaseContractFees(contractHash string)
- func (c *Store) ResetTransferredBytes(contractHash string, fileHash []byte) error
- func (c *Store) SetContractFileDownloadContexts(key string, ctxData ContextFileDownloadData)
- func (c *Store) SetError(contractHash string, fileHash []byte, errorMessage string)
- func (c *Store) SetFileDecryptionStatus(contractHash string, fileHash []byte, decryptionStatus FileDecryptionStatus)
- func (c *Store) SetFilePartDownloadError(contractHash string, fileHash []byte, fileNamePart, errorMessage string)
- func (c *Store) SetFileSize(contractHash string, fileHash []byte, fileSize uint64)
- func (c *Store) SetKeyIVEncryptionTypeRandomizedFileSegments(contractHash string, fileHash []byte, key, iv, merkleRootHash []byte, ...) error
- func (c *Store) SetMerkleTreeNodes(contractHash string, fileHash []byte, merkleTreeNodes [][]byte) error
- func (c *Store) SetProofOfTransferVerified(contractHash string, fileHash []byte, verified bool) error
- func (c *Store) SetReceivedUnencryptedDataFromFileHoster(contractHash string, fileHash []byte, transferred bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BytesTransferStats ¶ added in v1.1.9
type BytesTransferStats struct { FromByteRange int64 ToByteRange int64 DestinationFilePath string FilePartName string BytesTransfer uint64 ErrorMessage string }
BytesTransferStats represents the metadata of a transferred data file part.
type ContextFileDownloadData ¶ added in v1.1.8
type ContextFileDownloadData struct { From int64 To int64 Ctx context.Context Cancel context.CancelFunc }
ContextFileDownloadData
type FileDecryptionStatus ¶
type FileDecryptionStatus string
FileDecryptionStatus represents the file decryption status.
const ( FileNotDecrypted FileDecryptionStatus = "" FileDecrypted FileDecryptionStatus = "decrypted" FileDecrypting FileDecryptionStatus = "decrypting" FileDecryptionError FileDecryptionStatus = "decryption_error" )
type FileInfo ¶
type FileInfo struct { FileSize uint64 Key []byte IV []byte MerkleRootHash []byte FileHash []byte RandomSegments []int MerkleTreeNodes [][]byte EncryptionType common.EncryptionType ProofOfTransferVerified bool ReceivedUnencryptedDataFromFileHoster bool Error string FileDecryptionStatus FileDecryptionStatus }
FileInfo represents a contract with the file information.
type Interface ¶
type Interface interface { CreateContract(contract *messages.DownloadContractProto) error GetContract(contractHash string) (*messages.DownloadContractProto, error) GetContractFileInfo(contractHash string, fileHash []byte) (FileInfo, error) SetMerkleTreeNodes(contractHash string, fileHash []byte, merkleTreeNodes [][]byte) error SetKeyIVEncryptionTypeRandomizedFileSegments(contractHash string, fileHash []byte, key, iv, merkleRootHash []byte, encryptionType common.EncryptionType, randomizedSegments []int, fileSize uint64) error SetProofOfTransferVerified(contractHash string, fileHash []byte, verified bool) error SetReceivedUnencryptedDataFromFileHoster(contractHash string, fileHash []byte, transferred bool) error DeleteContract(contractHash string) error GetContractFiles(contractHash string) ([]FileInfo, error) ReleaseContractFees(contractHash string) GetReleaseContractFeesStatus(contractHash string) bool LoadFromDB() error IncrementTransferredBytes(contractHash string, fileHash []byte, fileNamePart, destinationFilePath string, filePartFromRange, filePartToRange int64, count uint64) SetFilePartDownloadError(contractHash string, fileHash []byte, fileNamePart, errorMessage string) GetTransferredBytes(contractHash string, fileHash []byte) uint64 SetError(contractHash string, fileHash []byte, errorMessage string) SetFileSize(contractHash string, fileHash []byte, fileSize uint64) SetFileDecryptionStatus(contractHash string, fileHash []byte, decryptionStatus FileDecryptionStatus) GetDownoadedFilePartInfos(contractHash string, fileHash []byte) []BytesTransferStats PurgeInactiveContracts(int64) error SetContractFileDownloadContexts(key string, ctxData ContextFileDownloadData) CancelContractFileDownloadContexts(key string) error PauseContractFileDownload(contractHash string, fileHash []byte) ClearPausedFileDownload(contractHash string, fileHash []byte) IsPausedFileDownload(contractHash string, fileHash []byte) bool ResetTransferredBytes(contractHash string, fileHash []byte) error }
Interface defines the functionalities of contract store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents the contract stores.
func (*Store) CancelContractFileDownloadContexts ¶ added in v1.1.8
CancelContractFileDownloadContexts cancels all the contexts file part downloads. key is ContractHash + FileHash
func (*Store) ClearPausedFileDownload ¶ added in v1.1.29
ClearPausedFileDownload clears a file download.
func (*Store) CreateContract ¶
func (c *Store) CreateContract(contract *messages.DownloadContractProto) error
CreateContract creates a contract with the zero values for file information
func (*Store) Debug ¶
func (c *Store) Debug(w http.ResponseWriter, r *http.Request)
Debug serves the internal state
func (*Store) DeleteContract ¶
DeleteContract removes a contract.
func (*Store) GetContract ¶
func (c *Store) GetContract(contractHash string) (*messages.DownloadContractProto, error)
GetContract get a contract.
func (*Store) GetContractFileInfo ¶
GetContractFileInfo returns the file info given a contract hash and file hash
func (*Store) GetContractFiles ¶
GetContractFiles returns the files info given a contract hash
func (*Store) GetDownoadedFilePartInfos ¶ added in v1.1.9
func (c *Store) GetDownoadedFilePartInfos(contractHash string, fileHash []byte) []BytesTransferStats
GetDownoadedFilePartInfos gets the downloaded file part infos.
func (*Store) GetReleaseContractFeesStatus ¶
GetReleaseContractFeesStatus returns true if contract fees were released.
func (*Store) GetTransferredBytes ¶ added in v1.1.17
GetTransferredBytes gets the transferred bytes for a file.
func (*Store) IncrementTransferredBytes ¶ added in v1.1.17
func (c *Store) IncrementTransferredBytes(contractHash string, fileHash []byte, fileNamePart, destinationFilePath string, filePartFromRange, filePartToRange int64, count uint64)
IncrementTransferredBytes increments the number of bytes transferred for a file.
func (*Store) IsPausedFileDownload ¶ added in v1.1.29
IsPausedFileDownload returns true if a file is paused.
func (*Store) LoadFromDB ¶
LoadFromDB loads the persisted data into memory.
func (*Store) PauseContractFileDownload ¶ added in v1.1.29
PauseContractFileDownload pauses a file download.
func (*Store) PurgeInactiveContracts ¶ added in v1.1.7
PurgeInactiveContracts removes inactive contracts Purge after 5 days (60 * 60 * 24 * 5)
func (*Store) ReleaseContractFees ¶
ReleaseContractFees stores an inmem indication that contract fees were released to file hoster.
func (*Store) ResetTransferredBytes ¶ added in v1.1.17
ResetTransferredBytes resets file transfer bytes to zero.
func (*Store) SetContractFileDownloadContexts ¶ added in v1.1.8
func (c *Store) SetContractFileDownloadContexts(key string, ctxData ContextFileDownloadData)
SetContractFileDownloadContexts stores the contexts for downloading file parts. these contexts can be canceled in future.
func (*Store) SetFileDecryptionStatus ¶
func (c *Store) SetFileDecryptionStatus(contractHash string, fileHash []byte, decryptionStatus FileDecryptionStatus)
SetFileDecryptionStatus sets a file encryption status.
func (*Store) SetFilePartDownloadError ¶
func (c *Store) SetFilePartDownloadError(contractHash string, fileHash []byte, fileNamePart, errorMessage string)
SetFilePartDownloadError sets an error for a file part download.
func (*Store) SetFileSize ¶
SetFileSize sets a file size
func (*Store) SetKeyIVEncryptionTypeRandomizedFileSegments ¶
func (c *Store) SetKeyIVEncryptionTypeRandomizedFileSegments(contractHash string, fileHash []byte, key, iv, merkleRootHash []byte, encryptionType common.EncryptionType, randomizedSegments []int, fileSize uint64) error
SetKeyIVEncryptionTypeRandomizedFileSegments sets the key and iv, encryption type and randomized segments of the of file.
func (*Store) SetMerkleTreeNodes ¶
func (c *Store) SetMerkleTreeNodes(contractHash string, fileHash []byte, merkleTreeNodes [][]byte) error
SetMerkleTreeNodes sets a merkle tree nodes of the file.