use crate::error::{Error, VerifyError};
pub trait PowConfig: Clone {
fn difficulty(&self) -> u32;
}
pub trait PowProof {
fn id(&self) -> u64;
}
pub trait PowBundle {
type Proof: PowProof;
type Config: PowConfig;
fn proofs(&self) -> &[Self::Proof];
fn config(&self) -> &Self::Config;
fn master_challenge(&self) -> &[u8; 32];
fn len(&self) -> usize {
self.proofs().len()
}
fn is_empty(&self) -> bool {
self.proofs().is_empty()
}
fn insert_proof(&mut self, proof: Self::Proof) -> Result<(), VerifyError>;
fn verify_strict(
&self,
min_difficulty: u32,
min_required_proofs: usize,
) -> Result<(), VerifyError>;
}
pub trait PowEngine {
type Bundle: PowBundle;
fn solve_bundle(&mut self, master_challenge: [u8; 32]) -> Result<Self::Bundle, Error>;
fn resume(&mut self, existing: Self::Bundle) -> Result<Self::Bundle, Error>;
}