penumbra_app/server/
snapshot.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::{
    future::Future,
    pin::Pin,
    task::{Context, Poll},
};

use futures::FutureExt;
use tendermint::v0_37::abci::{SnapshotRequest, SnapshotResponse};
use tower_abci::BoxError;

#[derive(Clone, Debug)]
pub struct Snapshot {}

impl tower_service::Service<SnapshotRequest> for Snapshot {
    type Response = SnapshotResponse;
    type Error = BoxError;
    type Future =
        Pin<Box<dyn Future<Output = Result<SnapshotResponse, BoxError>> + Send + 'static>>;

    fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
        Poll::Ready(Ok(()))
    }

    fn call(&mut self, req: SnapshotRequest) -> Self::Future {
        // No-op, we don't implement snapshot support
        use SnapshotRequest as Request;
        use SnapshotResponse as Response;
        async move {
            Ok(match req {
                Request::ListSnapshots => Response::ListSnapshots(Default::default()),
                Request::OfferSnapshot(_) => Response::OfferSnapshot(Default::default()),
                Request::LoadSnapshotChunk(_) => Response::LoadSnapshotChunk(Default::default()),
                Request::ApplySnapshotChunk(_) => Response::ApplySnapshotChunk(Default::default()),
            })
        }
        .boxed()
    }
}