Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateDirHash(d *FileDirInfo) string
- func DeleteFile(d *FileDirInfo, path string) error
- func GetBlobberJson(b *Blobber) string
- func GetFileContentType(out *os.File) (string, error)
- func GetJsonFromDirTree(d *FileDirInfo) string
- func Hash(text string) string
- func HashStringToBytes(hash string) []byte
- func MHash(h1 string, h2 string) string
- func NewCommitRequest(baseUrl, allocation string, client ClientConfig, body io.Reader) (*http.Request, error)
- func NewConnectionId() int64
- func NewDeleteRequest(baseUrl, allocation string, client ClientConfig, body io.Reader) (*http.Request, error)
- func NewDownloadRequest(baseUrl, allocation string, client ClientConfig, body io.Reader) (*http.Request, error)
- func NewFileMetaRequest(baseUrl string, allocation string, client ClientConfig, body io.Reader) (*http.Request, error)
- func NewLatestReadMarkerRequest(baseUrl string, client ClientConfig) (*http.Request, error)
- func NewListRequest(baseUrl, allocation string, client ClientConfig, path string) (*http.Request, error)
- func NewStatsRequest(baseUrl, allocation string, client ClientConfig, path string) (*http.Request, error)
- func NewUploadRequest(baseUrl, allocation string, client ClientConfig, body io.Reader, update bool) (*http.Request, error)
- func Now() int64
- func SetBlobberDirTree(b *Blobber, j string) error
- func ToHex(buf []byte) string
- func VerifyMerklePath(hash string, path *MTPath, root string) bool
- type Blobber
- type ClientConfig
- type Connection
- func (c *Connection) AddFile(path, hash string, size int64) error
- func (c *Connection) DeleteFile(path string, size int64) error
- func (c *Connection) GetAllocationRoot(timestamp int64) string
- func (c *Connection) GetCommitData() string
- func (c *Connection) GetSize() int64
- func (c *Connection) Reset()
- func (c *Connection) UpdateFile(path, hash string, size int64) error
- type DeleteToken
- type FileConfig
- type FileDirInfo
- func AddDir(d *FileDirInfo, path string) *FileDirInfo
- func GetDirTreeFromJson(j string) (FileDirInfo, error)
- func GetFileInfo(d *FileDirInfo, path string) *FileDirInfo
- func InsertFile(d *FileDirInfo, path, hash string, size int64) (*FileDirInfo, error)
- func ListDir(d *FileDirInfo, path string) []FileDirInfo
- func NewDirTree() FileDirInfo
- type Hashable
- type MTPath
- type MarkerI
- type MerkleTree
- func (mt *MerkleTree) ComputeTree(hashes []Hashable)
- func (mt *MerkleTree) GetLeafIndex(hash Hashable) int
- func (mt *MerkleTree) GetPath(hash Hashable) *MTPath
- func (mt *MerkleTree) GetPathByIndex(idx int) *MTPath
- func (mt *MerkleTree) GetRoot() string
- func (mt *MerkleTree) GetTree() []string
- func (mt *MerkleTree) SetTree(leavesCount int, tree []string) error
- func (mt *MerkleTree) VerifyPath(hash Hashable, path *MTPath) bool
- type MerkleTreeI
- type OperationStatus
- type ReadMarker
- type SecureSerializableValue
- type SecureSerializableValueI
- type Serializable
- type StringHashable
- type WriteMarker
Constants ¶
const COMMIT_ENDPOINT = "/v1/connection/commit/"
const CONNECTION_ENDPOINT = "/v1/connection/details/"
const DOWNLOAD_ENDPOINT = "/v1/file/download/"
const FILE_META_ENDPOINT = "/v1/file/meta/"
const FILE_STATS_ENDPOINT = "/v1/file/stats/"
const LATEST_READ_MARKER = "/v1/readmarker/latest"
const LIST_ENDPOINT = "/v1/file/list/"
const UPLOAD_ENDPOINT = "/v1/file/upload/"
Variables ¶
var (
FILEEXISTS = errors.New("File already exists")
)
Functions ¶
func CalculateDirHash ¶
func CalculateDirHash(d *FileDirInfo) string
func DeleteFile ¶
func DeleteFile(d *FileDirInfo, path string) error
func GetBlobberJson ¶
func GetJsonFromDirTree ¶
func GetJsonFromDirTree(d *FileDirInfo) string
func HashStringToBytes ¶
HashStringToBytes - convert a hex hash string to bytes
func NewCommitRequest ¶
func NewConnectionId ¶
func NewConnectionId() int64
func NewDeleteRequest ¶
func NewDownloadRequest ¶
func NewFileMetaRequest ¶
func NewLatestReadMarkerRequest ¶
func NewLatestReadMarkerRequest(baseUrl string, client ClientConfig) (*http.Request, error)
func NewListRequest ¶
func NewStatsRequest ¶
func NewUploadRequest ¶
func SetBlobberDirTree ¶
Types ¶
type Blobber ¶
type Blobber struct {
Id string `json:"id"`
UrlRoot string `json:"url"`
ReadCounter int64 `json:"counter"`
DirTree FileDirInfo `json:"tree,omit_empty"`
ConnObj Connection `json:"-"`
}
func GetBlobbers ¶
type ClientConfig ¶
type ClientConfig struct {
Id string `json:"id"`
PublicKey string `json:"public_key"`
PrivateKey string `json:"private_key"`
}
func GetClientConfig ¶
func GetClientConfig(j string) (ClientConfig, error)
type Connection ¶
type Connection struct {
ConnectionId int64
DirTree FileDirInfo
// contains filtered or unexported fields
}
func (*Connection) DeleteFile ¶
func (c *Connection) DeleteFile(path string, size int64) error
func (*Connection) GetAllocationRoot ¶
func (c *Connection) GetAllocationRoot(timestamp int64) string
func (*Connection) GetCommitData ¶
func (c *Connection) GetCommitData() string
func (*Connection) GetSize ¶
func (c *Connection) GetSize() int64
func (*Connection) Reset ¶
func (c *Connection) Reset()
func (*Connection) UpdateFile ¶
func (c *Connection) UpdateFile(path, hash string, size int64) error
type DeleteToken ¶
type DeleteToken struct {
FilePathHash string `json:"file_path_hash"`
FileRefHash string `json:"file_ref_hash"`
AllocationID string `json:"allocation_id"`
Size int64 `json:"size"`
BlobberID string `json:"blobber_id"`
Timestamp int64 `json:"timestamp"`
ClientID string `json:"client_id"`
Signature string `json:"signature"`
Status int `json:"status"`
}
func NewDeleteToken ¶
func NewDeleteToken() *DeleteToken
func (*DeleteToken) GetHash ¶
func (dt *DeleteToken) GetHash() string
func (*DeleteToken) Sign ¶
func (dt *DeleteToken) Sign(privateKey string) error
type FileConfig ¶
type FileConfig struct {
Name string `json:"Name"`
Path string `json:"Path"`
Size int64 `json:"Size"`
Type string `json:"Type"`
ActualHash string
FileHash hash.Hash
FileHashWr io.Writer
Remaining int64
}
func GetFileConfig ¶
func GetFileConfig(j string) (FileConfig, error)
type FileDirInfo ¶
type FileDirInfo struct {
Type string `json:"type"`
Name string `json:"name"`
Hash string `json:"hash"`
Size int64 `json:"size,omit_empty"`
Meta map[string]interface{} `json:"meta_data",omit_empty`
Children []FileDirInfo `json:"children,omit_empty"`
}
func AddDir ¶
func AddDir(d *FileDirInfo, path string) *FileDirInfo
func GetDirTreeFromJson ¶
func GetDirTreeFromJson(j string) (FileDirInfo, error)
func GetFileInfo ¶
func GetFileInfo(d *FileDirInfo, path string) *FileDirInfo
func InsertFile ¶
func InsertFile(d *FileDirInfo, path, hash string, size int64) (*FileDirInfo, error)
func ListDir ¶
func ListDir(d *FileDirInfo, path string) []FileDirInfo
func NewDirTree ¶
func NewDirTree() FileDirInfo
func (*FileDirInfo) GetInfoHash ¶
func (fi *FileDirInfo) GetInfoHash() string
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
MerkleTree - A data structure that implements MerkleTreeI interface
func (*MerkleTree) ComputeTree ¶
func (mt *MerkleTree) ComputeTree(hashes []Hashable)
ComputeTree - given the leaf nodes, compute the merkle tree
func (*MerkleTree) GetLeafIndex ¶
func (mt *MerkleTree) GetLeafIndex(hash Hashable) int
GetLeafIndex - Get the index of the leaf node in the tree
func (*MerkleTree) GetPath ¶
func (mt *MerkleTree) GetPath(hash Hashable) *MTPath
GetPath - get the path that can be used to verify the merkle tree
func (*MerkleTree) GetPathByIndex ¶
func (mt *MerkleTree) GetPathByIndex(idx int) *MTPath
GetPathByIndex - get the path of a leaf node at index i
func (*MerkleTree) GetRoot ¶
func (mt *MerkleTree) GetRoot() string
GetRoot - get the root of the merkle tree
func (*MerkleTree) GetTree ¶
func (mt *MerkleTree) GetTree() []string
GetTree - get the entire merkle tree
func (*MerkleTree) SetTree ¶
func (mt *MerkleTree) SetTree(leavesCount int, tree []string) error
SetTree - set the entire merkle tree
func (*MerkleTree) VerifyPath ¶
func (mt *MerkleTree) VerifyPath(hash Hashable, path *MTPath) bool
VerifyPath - given a leaf node and the path, verify that the node is part of the tree
type MerkleTreeI ¶
type MerkleTreeI interface {
//API to create a tree from leaf nodes
ComputeTree(hashes []Hashable)
GetRoot() string
GetTree() []string
//API to load an existing tree
SetTree(leavesCount int, tree []string) error
// API for verification when the leaf node is known
GetPath(hash Hashable) *MTPath // Server needs to provide this
VerifyPath(hash Hashable, path *MTPath) bool //This is only required by a client but useful for testing
/* API for random verification when the leaf node is uknown
(verification of the data to hash used as leaf node is outside this API) */
GetPathByIndex(idx int) *MTPath
}
MerkleTreeI - a merkle tree interface required for constructing and providing verification
type OperationStatus ¶
type ReadMarker ¶
type ReadMarker struct {
ClientID string `json:"client_id"`
ClientPublicKey string `json:"client_public_key"`
BlobberID string `json:"blobber_id"`
AllocationID string `json:"allocation_id"`
OwnerID string `json:"owner_id"`
Timestamp int64 `json:"timestamp"`
ReadCounter int64 `json:"counter"`
Signature string `json:"signature"`
}
func NewReadMarker ¶
func NewReadMarker() *ReadMarker
func (*ReadMarker) GetHash ¶
func (rm *ReadMarker) GetHash() string
func (*ReadMarker) Sign ¶
func (rm *ReadMarker) Sign(privateKey string) error
type SecureSerializableValue ¶
type SecureSerializableValue struct {
Buffer []byte
}
SecureSerializableValue - a proxy persisted value that just tracks the encoded bytes of a persisted value
func (*SecureSerializableValue) Decode ¶
func (spv *SecureSerializableValue) Decode(buf []byte) error
Decode - implement interface
func (*SecureSerializableValue) Encode ¶
func (spv *SecureSerializableValue) Encode() []byte
Encode - implement interface
func (*SecureSerializableValue) GetHash ¶
func (spv *SecureSerializableValue) GetHash() string
GetHash - implement interface
func (*SecureSerializableValue) GetHashBytes ¶
func (spv *SecureSerializableValue) GetHashBytes() []byte
GetHashBytes - implement interface
type SecureSerializableValueI ¶
type SecureSerializableValueI interface {
Serializable
Hashable
}
SecureSerializableValueI an interface that makes a serializable value secure with hashing
type Serializable ¶
Serializable interface
type StringHashable ¶
type StringHashable struct {
Hash string
}
func NewStringHashable ¶
func NewStringHashable(hash string) *StringHashable
func (*StringHashable) GetHash ¶
func (sh *StringHashable) GetHash() string
func (*StringHashable) GetHashBytes ¶
func (sh *StringHashable) GetHashBytes() []byte
type WriteMarker ¶
type WriteMarker struct {
AllocationRoot string `json:"allocation_root"`
PreviousAllocationRoot string `json:"prev_allocation_root"`
AllocationID string `json:"allocation_id"`
Size int64 `json:"size"`
BlobberID string `json:"blobber_id"`
Timestamp int64 `json:"timestamp"`
ClientID string `json:"client_id"`
Signature string `json:"signature"`
}
func NewWriteMarker ¶
func NewWriteMarker() *WriteMarker
func (*WriteMarker) GetHash ¶
func (wm *WriteMarker) GetHash() string
func (*WriteMarker) Sign ¶
func (wm *WriteMarker) Sign(privateKey string) error