| 1 |
//! ZephyrFS Node Library |
| 2 |
//! |
| 3 |
//! Core library for ZephyrFS distributed P2P storage system. |
| 4 |
//! Provides cryptographic primitives, storage management, network protocols, |
| 5 |
//! comprehensive security systems, and contribution-based resource allocation |
| 6 |
//! with zero-knowledge architecture. |
| 7 |
|
| 8 |
pub mod config; |
| 9 |
pub mod network; |
| 10 |
pub mod storage; |
| 11 |
pub mod protocol; |
| 12 |
pub mod node_manager; |
| 13 |
pub mod crypto; |
| 14 |
pub mod coordinator; |
| 15 |
|
| 16 |
// Phase 4.3: Enhanced Security & Malicious Content Protection |
| 17 |
pub mod security; |
| 18 |
pub mod verification; |
| 19 |
pub mod audit; |
| 20 |
pub mod proof; |
| 21 |
|
| 22 |
/// Serializable wrapper for std::time::Instant |
| 23 |
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] |
| 24 |
pub struct SerializableInstant { |
| 25 |
inner: std::time::Instant, |
| 26 |
} |
| 27 |
|
| 28 |
impl SerializableInstant { |
| 29 |
pub fn now() -> Self { |
| 30 |
Self { |
| 31 |
inner: std::time::Instant::now(), |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
pub fn elapsed(&self) -> std::time::Duration { |
| 36 |
self.inner.elapsed() |
| 37 |
} |
| 38 |
|
| 39 |
pub fn duration_since(&self, earlier: Self) -> std::time::Duration { |
| 40 |
self.inner.duration_since(earlier.inner) |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
impl serde::Serialize for SerializableInstant { |
| 45 |
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> |
| 46 |
where |
| 47 |
S: serde::Serializer, |
| 48 |
{ |
| 49 |
// Serialize as milliseconds since creation (approximate) |
| 50 |
serializer.serialize_u64(0) // Placeholder - in production use proper epoch handling |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
impl<'de> serde::Deserialize<'de> for SerializableInstant { |
| 55 |
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
| 56 |
where |
| 57 |
D: serde::Deserializer<'de>, |
| 58 |
{ |
| 59 |
let _millis: u64 = serde::Deserialize::deserialize(deserializer)?; |
| 60 |
Ok(Self::now()) // Placeholder - in production reconstruct from epoch |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
impl std::ops::Add<std::time::Duration> for SerializableInstant { |
| 65 |
type Output = Self; |
| 66 |
|
| 67 |
fn add(self, duration: std::time::Duration) -> Self::Output { |
| 68 |
Self { |
| 69 |
inner: self.inner + duration, |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
impl std::ops::Sub<std::time::Duration> for SerializableInstant { |
| 75 |
type Output = Self; |
| 76 |
|
| 77 |
fn sub(self, duration: std::time::Duration) -> Self::Output { |
| 78 |
Self { |
| 79 |
inner: self.inner - duration, |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
impl std::ops::Sub<SerializableInstant> for SerializableInstant { |
| 85 |
type Output = std::time::Duration; |
| 86 |
|
| 87 |
fn sub(self, other: SerializableInstant) -> Self::Output { |
| 88 |
self.inner - other.inner |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
// Phase 6.2: Contribution-Based Resource Management |
| 93 |
pub mod economics; |
| 94 |
|
| 95 |
// Phase 6.3: Contribution-Based Resource Allocation |
| 96 |
pub mod allocation; |
| 97 |
|
| 98 |
// Phase 5.2: Smart Redundancy & Data Durability |
| 99 |
pub mod redundancy; |
| 100 |
|
| 101 |
pub use crypto::{ |
| 102 |
ZephyrCrypto, CryptoParams, ScryptParams, AesParams, HashParams, |
| 103 |
ContentHasher, VerificationHasher, EncryptedData, ContentId, HashAlgorithm |
| 104 |
}; |
| 105 |
|
| 106 |
// Core system exports |
| 107 |
pub use config::Config; |
| 108 |
pub use node_manager::{NodeManager, DistributionStrategy}; |
| 109 |
pub use storage::{StorageManager, StorageConfig}; |
| 110 |
|
| 111 |
// Phase 4.3: Security system exports |
| 112 |
pub use security::{ |
| 113 |
UnifiedSecurityManager, SecurityConfig, ChunkSecurityDecision, AccessDecision, |
| 114 |
SecurityClearance, ChunkSecurityStatus |
| 115 |
}; |
| 116 |
pub use verification::{ |
| 117 |
UnifiedVerificationManager, VerificationConfig, ComprehensiveVerificationResult, |
| 118 |
VerificationRecommendation |
| 119 |
}; |
| 120 |
pub use audit::{ |
| 121 |
UnifiedAuditManager, UnifiedAuditConfig, EnhancedTransparencyReport, |
| 122 |
AuditAlert, AlertSeverity |
| 123 |
}; |
| 124 |
pub use proof::{ |
| 125 |
UnifiedProofManager, UnifiedProofConfig, ComprehensiveChallenge, |
| 126 |
ComprehensiveVerificationResult as ProofVerificationResult, ProofStatistics |
| 127 |
}; |
| 128 |
|
| 129 |
// Phase 6.2: Contribution-based economic system exports |
| 130 |
pub use economics::{ |
| 131 |
ContributionTracker, UserContribution, NetworkContributionStats, PriorityLevel, AccountStatus, |
| 132 |
ContributionEconomicManager, SimpleReferralTracker, ContributionConfig |
| 133 |
}; |
| 134 |
// Phase 6.3: Contribution-based allocation system exports |
| 135 |
pub use allocation::{ |
| 136 |
ContributionBasedAllocator, AllocationDecision, AllocationRequest, AllocationStrategy, AllocationQuality, |
| 137 |
QualityTierManager, QualityTier, ServiceLevel, TierRequirements, TierBenefits, |
| 138 |
RegionalResourceBalancer, ContributionLoadBalancer, ResourceScheduler |
| 139 |
}; |
| 140 |
|
| 141 |
// Phase 6.6: Contribution-Based Smart Redundancy System |
| 142 |
pub use redundancy::{ |
| 143 |
IntelligentReplicationManager, GeographicOptimizer, ChunkHealthMonitor, |
| 144 |
AutoReplicationManager, ReplicationStrategy, GeographicDistribution, |
| 145 |
HealthStatus, ReplicationStatus, |
| 146 |
ContributionNodeSelector, ContributionReplicationManager, NodeContribution, NodeReliability |
| 147 |
}; |