Documentation
¶
Overview ¶
Package manifest provides structures and functions to create, save, load, and validate
Index ¶
- func CalculateFileHash(filePath string) (string, error)
- func GenerateBlobID() string
- type ChunkMeta
- type FarmerInfo
- type Manifest
- func (m *Manifest) GetChunkHash(index int) string
- func (m *Manifest) GetEncryptionKey() ([]byte, error)
- func (m *Manifest) GetFarmerForShard(shard ShardMeta) *FarmerInfo
- func (m *Manifest) GetFarmersForChunk(chunkIndex int) []FarmerInfo
- func (m *Manifest) GetShardsForChunk(chunkIndex int) []ShardMeta
- func (m *Manifest) Save(path string) error
- func (m *Manifest) Validate() error
- type ShardMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateFileHash ¶
CalculateFileHash computes SHA256 hash of entire file
func GenerateBlobID ¶ added in v0.1.2
func GenerateBlobID() string
GenerateBlobID creates a random 32-byte blob ID
Types ¶
type ChunkMeta ¶
type ChunkMeta struct {
Index int `json:"index"` // chunk index
Hash string `json:"hash"` // SHA256 of plaintext chunk
Size int `json:"size"` // size of chunk in bytes
}
ChunkMeta represents metadata for a file chunk
type FarmerInfo ¶
type FarmerInfo struct {
Index int `json:"index"` // farmer index (0-5)
Address string `json:"address"` // farmer wallet address
Endpoint string `json:"endpoint"` // HTTP endpoint (e.g., "https://farmer1.dbxn.io:4433")
Region string `json:"region"` // geographic region (e.g., "us-east-1")
}
type Manifest ¶
type Manifest struct {
Version string `json:"version"` // manifest version
BlobID string `json:"blob_id"` // unique blob identifier
FileName string `json:"file_name"` // original file name
FileSize int64 `json:"file_size"` // original file size in bytes
OriginalFileHash string `json:"original_file_hash"` // SHA256 hash of original file
ChunkSize int `json:"chunk_size"` // size of each chunk in bytes
ChunkCount int `json:"chunk_count"` // total number of chunks
DataShards int `json:"data_shards"` // 4 data shards per chunk
ParityShards int `json:"parity_shards"` // 2 parity shards per chunk
TotalShards int `json:"total_shards"` // 6 total shards per chunk
Chunks []ChunkMeta `json:"chunks"` // metadata for each chunk
Shards []ShardMeta `json:"shards"` // metadata for each shard
Farmers []FarmerInfo `json:"farmers"` // list of farmers storing the chunks
EncryptionKey string `json:"encryption_key"` // hex-encoded encryption key for chunks
CreatedAt time.Time `json:"created_at"` // timestamp of manifest creation
PublisherAddress string `json:"publisher_address"` // address of the publisher
}
Manifest represents the metadata for a blob
func New ¶
func New( blobID string, fileName string, fileSize int64, originalHash string, chunks []ChunkMeta, shards []ShardMeta, farmers []FarmerInfo, encKey []byte, publisher string, ) *Manifest
New creates a new manifest
func (*Manifest) GetChunkHash ¶
GetChunkHash returns hash for a given chunk index
func (*Manifest) GetEncryptionKey ¶
GetEncryptionKey returns the encryption key as bytes
func (*Manifest) GetFarmerForShard ¶
func (m *Manifest) GetFarmerForShard(shard ShardMeta) *FarmerInfo
GetFarmerForShard returns the FarmerInfo for a given shard
func (*Manifest) GetFarmersForChunk ¶
func (m *Manifest) GetFarmersForChunk(chunkIndex int) []FarmerInfo
GetFarmersForChunk returns unique farmers storing shards for a given chunk index
func (*Manifest) GetShardsForChunk ¶
GetShardsForChunk returns all shards metadata for a given chunk index
type ShardMeta ¶
type ShardMeta struct {
ChunkIndex int `json:"chunk_index"` // which chunk (0-99)
ShardIndex int `json:"shard_index"` // which shard (0-5)
Hash string `json:"hash"` // SHA256 of shard
Size int `json:"size"` // shard size in bytes
FarmerIndex int `json:"farmer_index"` // which farmer stores this
}
ShardMeta represents metadata for an erasure-coded shard