Skip to content

Commit 7d1405b

Browse files
apollo_proof_manager: component request handler
1 parent 8174e71 commit 7d1405b

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_proof_manager/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ workspace = true
1414
[dependencies]
1515
apollo_proof_manager_config.workspace = true
1616
apollo_infra.workspace = true
17+
apollo_proof_manager_types.workspace = true
1718
async-trait.workspace = true
1819
hex.workspace = true
1920
starknet-types-core = { workspace = true, features = ["hash"] }
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use apollo_infra::component_definitions::ComponentRequestHandler;
2+
use apollo_infra::component_server::{ConcurrentLocalComponentServer, RemoteComponentServer};
3+
use apollo_proof_manager_types::{ProofManagerError, ProofManagerRequest, ProofManagerResponse};
4+
use async_trait::async_trait;
5+
6+
use crate::proof_storage::ProofStorage;
7+
use crate::ProofManager;
8+
pub type LocalProofManagerServer =
9+
ConcurrentLocalComponentServer<ProofManager, ProofManagerRequest, ProofManagerResponse>;
10+
pub type RemoteProofManagerServer =
11+
RemoteComponentServer<ProofManagerRequest, ProofManagerResponse>;
12+
13+
#[async_trait]
14+
impl ComponentRequestHandler<ProofManagerRequest, ProofManagerResponse> for ProofManager {
15+
async fn handle_request(&mut self, request: ProofManagerRequest) -> ProofManagerResponse {
16+
match request {
17+
ProofManagerRequest::SetProof(facts_hash, proof) => ProofManagerResponse::SetProof(
18+
self.set_proof(facts_hash, proof)
19+
.map_err(|e| ProofManagerError::ProofStorage(e.to_string())),
20+
),
21+
ProofManagerRequest::GetProof(facts_hash) => ProofManagerResponse::GetProof(
22+
self.get_proof(facts_hash)
23+
.map_err(|e| ProofManagerError::ProofStorage(e.to_string())),
24+
),
25+
ProofManagerRequest::ContainsProof(facts_hash) => ProofManagerResponse::ContainsProof(
26+
self.contains_proof(facts_hash)
27+
.map_err(|e| ProofManagerError::ProofStorage(e.to_string())),
28+
),
29+
}
30+
}
31+
}

crates/apollo_proof_manager/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod communication;
12
pub mod proof_manager;
23
pub mod proof_storage;
34

0 commit comments

Comments
 (0)