fedimint_meta_common/
endpoint.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
use std::collections::BTreeMap;

use fedimint_core::PeerId;
use serde::{Deserialize, Serialize};

use crate::{MetaKey, MetaValue};

/// Submit a change of value for a given key. Guardians only.
pub const SUBMIT_ENDPOINT: &str = "submit";
/// Get consensus on the value of a given key
pub const GET_CONSENSUS_ENDPOINT: &str = "get_consensus";
/// Get revision of the consensus on the value of a given key
///
/// This is meant to avoid transmitting the whole value over
/// and over to clients that already have it, and are just checking
/// if it was updated.
pub const GET_CONSENSUS_REV_ENDPOINT: &str = "get_consensus_rev";
/// Get the list of pending submissions for a given key. Guardians only.
pub const GET_SUBMISSIONS_ENDPOINT: &str = "get_submission";

#[derive(Debug, Serialize, Deserialize)]
pub struct SubmitRequest {
    pub key: MetaKey,
    pub value: MetaValue,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetConsensusRequest(pub MetaKey);

#[derive(Debug, Serialize, Deserialize)]
pub struct GetSubmissionsRequest(pub MetaKey);

pub type GetSubmissionResponse = BTreeMap<PeerId, MetaValue>;