manifest

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package manifest provides structures and functions to create, save, load, and validate

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateFileHash

func CalculateFileHash(filePath string) (string, error)

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 Load

func Load(path string) (*Manifest, error)

Load reads manifest from JSON file

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

func (m *Manifest) GetChunkHash(index int) string

GetChunkHash returns hash for a given chunk index

func (*Manifest) GetEncryptionKey

func (m *Manifest) GetEncryptionKey() ([]byte, error)

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

func (m *Manifest) GetShardsForChunk(chunkIndex int) []ShardMeta

GetShardsForChunk returns all shards metadata for a given chunk index

func (*Manifest) Save

func (m *Manifest) Save(path string) error

Save writes manifest to JSON file

func (*Manifest) Validate added in v0.1.2

func (m *Manifest) Validate() error

Validate checks the integrity of the manifest

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

Jump to

Keyboard shortcuts

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