randomfs

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Block sizes for different file categories
	NanoBlockSize = 1024    // 1KB for small files
	MiniBlockSize = 65536   // 64KB for medium files
	BlockSize     = 1048576 // 1MB for large files

	// Thresholds for block size selection
	NanoThreshold = 100 * 1024       // 100KB
	MiniThreshold = 10 * 1024 * 1024 // 10MB

	// Protocol version
	ProtocolVersion = "v4"

	// Default IPFS API endpoint
	DefaultIPFSEndpoint = "http://localhost:5001"
)

Variables

This section is empty.

Functions

func DeRandomizeBlock

func DeRandomizeBlock(block []byte, dataSize int) []byte

DeRandomizeBlock recovers original data using the OFF System algorithm This function is called for each block in the descriptor set

func GenerateRandomBlocks

func GenerateRandomBlocks(data []byte, blockSize int) ([][]byte, error)

GenerateRandomBlocks creates randomized blocks using the OFF System algorithm

func XORBlocks

func XORBlocks(a, b []byte) []byte

XORBlocks returns the XOR of two byte slices (up to the length of the shorter slice)

func XORBlocksInPlace

func XORBlocksInPlace(a, b []byte)

XORBlocksInPlace XORs b into a in place (up to the length of b)

Types

type BlockCache

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

BlockCache manages block storage and retrieval

type FileRepresentation

type FileRepresentation struct {
	FileName    string     `json:"filename"`
	FileSize    int64      `json:"filesize"`
	BlockHashes []string   `json:"block_hashes"`
	BlockSize   int        `json:"block_size"`
	Timestamp   int64      `json:"timestamp"`
	ContentType string     `json:"content_type"`
	Version     string     `json:"version"`
	Descriptors [][]string `json:"descriptors"` // OFF System descriptor lists
}

FileRepresentation contains the metadata needed to reconstruct a file

type RandomFS

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

RandomFS represents the main filesystem instance

func NewRandomFS

func NewRandomFS(ipfsAPI string, dataDir string, cacheSize int64) (*RandomFS, error)

NewRandomFS creates a new RandomFS instance

func NewRandomFSWithOptions

func NewRandomFSWithOptions(ipfsAPI string, dataDir string, cacheSize int64, skipIPFSTest bool) (*RandomFS, error)

NewRandomFSWithOptions creates a new RandomFS instance with options

func NewRandomFSWithoutIPFS

func NewRandomFSWithoutIPFS(dataDir string, cacheSize int64) (*RandomFS, error)

NewRandomFSWithoutIPFS creates a new RandomFS instance without requiring IPFS

func (*RandomFS) GetStats

func (rfs *RandomFS) GetStats() Stats

GetStats returns current system statistics

func (*RandomFS) RetrieveFile

func (rfs *RandomFS) RetrieveFile(repHash string) ([]byte, *FileRepresentation, error)

RetrieveFile retrieves and reconstructs a file from its representation hash using OFF System algorithm

func (*RandomFS) StoreFile

func (rfs *RandomFS) StoreFile(filename string, data []byte, contentType string) (*RandomURL, error)

StoreFile stores a file in the randomized block format using OFF System algorithm

type RandomURL

type RandomURL struct {
	Scheme    string
	Host      string
	Version   string
	FileName  string
	FileSize  int64
	RepHash   string
	Timestamp int64
}

RandomURL represents a rd:// URL for file access

func ParseRandomURL

func ParseRandomURL(rawURL string) (*RandomURL, error)

ParseRandomURL parses a rd:// URL

func (*RandomURL) String

func (ru *RandomURL) String() string

String returns the string representation of a RandomURL

type Stats

type Stats struct {
	FilesStored     int64 `json:"files_stored"`
	BlocksGenerated int64 `json:"blocks_generated"`
	TotalSize       int64 `json:"total_size"`
	CacheHits       int64 `json:"cache_hits"`
	CacheMisses     int64 `json:"cache_misses"`
}

Stats holds system statistics

Jump to

Keyboard shortcuts

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