The Proxy
Guarding access to the heavy STARK prover.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Proxy
ARCANUM SCHOOL: Abjuration // Guarding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CAIRO PATTERN //
trait IProver { fn prove(self: @ProverProxy, data: felt252) -> felt252; }
#[derive(Copy, Drop)]
struct HeavyProver {}
#[derive(Copy, Drop)]
struct ProverProxy { has_access: bool, heavy: HeavyProver }
impl ProxyImpl of IProver {
fn prove(self: @ProverProxy, data: felt252) -> felt252 {
if *self.has_access {
'proof_generated'
} else {
'access_denied'
}
}
}
A sentinel that checks permissions or caches results before invoking the costly underlying proving ritual.
Runic Tags:
#cairo
#design-pattern
#proxy