use crate::imp::core::bytes::Bytes32;
use crate::imp::core::merkle::MerkleTree;
use alloc::string::String;
pub const MAX_STORE_BYTES: u64 = 128_000_000;
#[cfg(feature = "std")]
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SecretSalt(pub [u8; 32]);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Visibility {
Public,
Private(SecretSalt),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StoreConfig {
pub store_id: Bytes32,
pub data_dir: String,
pub max_size: u64,
pub visibility: Visibility,
pub label: Option<String>,
pub description: Option<String>,
}
pub type GenerationId = u64;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GenerationState {
pub id: u64,
pub root: Bytes32,
pub timestamp: u64,
}
#[derive(Debug, Clone)]
pub struct Generation {
pub state: GenerationState,
pub tree: MerkleTree,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ChunkerConfig {
pub min_size: usize,
pub target_size: usize,
pub max_size: usize,
pub mask: u64,
}
impl Default for ChunkerConfig {
fn default() -> Self {
ChunkerConfig {
min_size: 16 * 1024,
target_size: 64 * 1024,
max_size: 256 * 1024,
mask: 0xFFFF,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HostImportsConfig {
pub return_buffer_capacity: usize,
pub max_return_buffer_size: usize,
pub max_random_bytes: u32,
pub host_version: String,
}
impl Default for HostImportsConfig {
fn default() -> Self {
HostImportsConfig {
return_buffer_capacity: 64 * 1024,
max_return_buffer_size: 16 * 1024 * 1024,
max_random_bytes: 1024,
host_version: String::new(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TrustedHostKey {
pub public_key: [u8; 48],
pub label: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct CompilationStats {
pub chunk_count: u64,
pub total_bytes: u64,
pub generation_count: u64,
}
#[cfg(feature = "std")]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompilationResult {
pub store_id: Bytes32,
pub roothash: Bytes32,
pub output_path: PathBuf,
pub output_size: u64,
pub stats: CompilationStats,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CompilerError {
NoTrustedKeys,
Io(String),
Validation(String),
}