Documentation ¶
Index ¶
- type BytesTransferStats
- type ContextFileDownloadData
- type FileDecryptionStatus
- type FileInfo
- type Interface
- type Store
- func (c *Store) CancelContractFileDownloadContexts(key string) error
- 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) GetTransferedBytes(contractHash string, fileHash []byte) uint64
- func (c *Store) IncrementTransferedBytes(contractHash string, fileHash []byte, fileNamePart, destinationFilePath string, ...)
- func (c *Store) LoadFromDB() error
- func (c *Store) PurgeInactiveContracts(purgeAfterSeconds int64) error
- func (c *Store) ReleaseContractFees(contractHash string)
- func (c *Store) ResetTransferedBytes(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, transfered 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 transfered 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, transfered bool) error DeleteContract(contractHash string) error GetContractFiles(contractHash string) ([]FileInfo, error) ReleaseContractFees(contractHash string) GetReleaseContractFeesStatus(contractHash string) bool LoadFromDB() error IncrementTransferedBytes(contractHash string, fileHash []byte, fileNamePart, destinationFilePath string, filePartFromRange, filePartToRange int64, count uint64) SetFilePartDownloadError(contractHash string, fileHash []byte, fileNamePart, errorMessage string) GetTransferedBytes(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 ResetTransferedBytes(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.
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) GetTransferedBytes ¶
GetTransferedBytes gets the transfered bytes for a file.
func (*Store) IncrementTransferedBytes ¶
func (c *Store) IncrementTransferedBytes(contractHash string, fileHash []byte, fileNamePart, destinationFilePath string, filePartFromRange, filePartToRange int64, count uint64)
IncrementTransferedBytes increments the number of bytes transfered for a file.
func (*Store) LoadFromDB ¶
LoadFromDB loads the persisted data into memory.
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) ResetTransferedBytes ¶ added in v1.1.8
ResetTransferedBytes 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.