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
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

use crate::common::{Payload, PayloadFilter, Round};
use anyhow::Result;
use futures::channel::oneshot;
use std::{fmt, fmt::Formatter};

/// Message sent from Consensus to QuorumStore.
pub enum ConsensusRequest {
    /// Request to pull block to submit to consensus.
    GetBlockRequest(
        // max block size
        u64,
        // block payloads to exclude from the requested block
        PayloadFilter,
        // callback to respond to
        oneshot::Sender<Result<ConsensusResponse>>,
    ),
    /// Request to clean quorum store at commit logical time
    CleanRequest(
        // epoch
        u64,
        // round
        Round,
        // callback to respond to
        oneshot::Sender<Result<ConsensusResponse>>,
    ),
}

impl fmt::Display for ConsensusRequest {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        match self {
            ConsensusRequest::GetBlockRequest(block_size, excluded, _) => {
                write!(
                    f,
                    "GetBlockRequest [block_size: {}, excluded: {}]",
                    block_size, excluded
                )
            }
            ConsensusRequest::CleanRequest(epoch, round, _) => {
                write!(f, "CleanRequest [epoch: {}, round: {}]", epoch, round)
            }
        }
    }
}

pub enum ConsensusResponse {
    GetBlockResponse(Payload),
    CleanResponse(),
}