Documentation ¶
Index ¶
- type FileDecryptionStatus
- type FileInfo
- type Interface
- type Store
- 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) GetDownoadedFilePartNames(contractHash string, fileHash []byte) []string
- 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) ReleaseContractFees(contractHash string)
- 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 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 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) GetDownoadedFilePartNames(contractHash string, fileHash []byte) []string }
Interface defines the functionalities of contract store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents the contract stores.
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) GetDownoadedFilePartNames ¶
GetDownoadedFilePartNames gets the downloaded file parts names in order.
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 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) ReleaseContractFees ¶
ReleaseContractFees stores an inmem indication that contract fees were released to file hoster.
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.