mod codec;
mod model;
mod verify;
pub use model::{
MAX_RESULT_PROOF_BYTES, ProofAnchor, ProofError, ProvenOperation, ProvenResult,
RESULT_PROOF_FORMAT_VERSION, ResultProof, ResultProofArtifact, VerificationLimits,
VerificationReport,
};
pub use verify::{read_result_proof, verify_result_proof, write_result_proof};
use hyphae_query::{Query, QueryResult, Record};
use hyphae_storage::SnapshotInfo;
use self::codec::{decode_proof, encode_proof, finalize_proof};
impl ResultProof {
pub fn for_get(
snapshot: &SnapshotInfo,
key: Vec<u8>,
result: Option<Record>,
) -> Result<Self, ProofError> {
finalize_proof(
ProofAnchor::from_snapshot(snapshot),
ProvenOperation::Get { key },
ProvenResult::Get(result),
)
}
pub fn for_query(
snapshot: &SnapshotInfo,
query: Query,
result: QueryResult,
) -> Result<Self, ProofError> {
finalize_proof(
ProofAnchor::from_snapshot(snapshot),
ProvenOperation::Query(query),
ProvenResult::Query(result),
)
}
pub fn to_bytes(&self) -> Result<Vec<u8>, ProofError> {
encode_proof(self)
}
pub fn from_bytes(encoded: &[u8]) -> Result<Self, ProofError> {
decode_proof(encoded)
}
}