synor/crates/synor-storage/src/lib.rs
2026-02-02 05:58:22 +05:30

97 lines
2.7 KiB
Rust

//! Synor Storage Layer
//!
//! Decentralized storage network for the Synor blockchain ecosystem.
//! Enables permanent, censorship-resistant storage of any file type.
//!
//! # Architecture
//!
//! The storage layer operates as L2 alongside the Synor blockchain (L1):
//! - **Content Addressing**: Files identified by cryptographic hash (CID)
//! - **Erasure Coding**: Data split with redundancy for fault tolerance
//! - **Storage Proofs**: Nodes prove they're storing data to earn rewards
//! - **Gateways**: HTTP access for web browsers
//!
//! # Example
//!
//! ```rust,ignore
//! use synor_storage::{ContentId, Chunker, StorageClient};
//!
//! // Upload a file
//! let data = std::fs::read("myfile.zip")?;
//! let cid = ContentId::from_content(&data);
//! client.store(cid, &data).await?;
//!
//! // Retrieve by CID
//! let retrieved = client.retrieve(&cid).await?;
//! ```
pub mod chunker;
pub mod cid;
pub mod deal;
pub mod erasure;
pub mod error;
pub mod proof;
// Database layer for blockchain state
pub mod cf;
pub mod db;
pub mod stores;
// CAR file support for trustless verification
pub mod car;
// Multi-pin redundancy service
pub mod pinning;
// Node module - storage node implementation
pub mod node;
// Gateway module - HTTP access to stored content
pub mod gateway;
pub use chunker::{Chunk, Chunker};
pub use cid::ContentId;
pub use error::{Error, Result};
pub use gateway::{CdnConfig, CdnProvider, Gateway, GatewayConfig, GatewayStats, SubdomainRoute};
pub use node::{NodeConfig, NodeState, NodeStats, StorageNode};
// CAR exports
pub use car::{CarBlock, CarBuilder, CarFile, CarHeader, TrustlessResponse};
// Pinning exports
pub use pinning::{
PinManager, PinManagerConfig, PinRecord, PinRequest, PinStatus, PinSummary, RedundancyLevel,
Region, StorageNode as PinStorageNode,
};
// Database exports for blockchain state storage
pub use db::{keys, Database, DatabaseConfig, DbError};
pub use stores::{
BlockBody, BlockStore, ChainState, ContractStateStore, ContractStore, GhostdagStore,
HeaderStore, MetadataStore, RelationsStore, StoredContract, StoredGhostdagData,
StoredRelations, StoredUtxo, TransactionStore, UtxoStore,
};
/// Storage layer configuration
#[derive(Debug, Clone)]
pub struct StorageConfig {
/// Chunk size in bytes (default: 1MB)
pub chunk_size: usize,
/// Number of data shards for erasure coding
pub data_shards: usize,
/// Number of parity shards for erasure coding
pub parity_shards: usize,
/// Replication factor (copies per shard)
pub replication_factor: usize,
}
impl Default for StorageConfig {
fn default() -> Self {
Self {
chunk_size: 1024 * 1024, // 1 MB
data_shards: 10,
parity_shards: 4,
replication_factor: 3,
}
}
}