2020-03-03 16:53:30 -08:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
|
2019-11-06 13:15:00 -08:00
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct CommitmentConfig {
|
|
|
|
pub commitment: CommitmentLevel,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for CommitmentConfig {
|
|
|
|
fn default() -> Self {
|
|
|
|
CommitmentConfig {
|
|
|
|
commitment: CommitmentLevel::Max,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CommitmentConfig {
|
|
|
|
pub fn recent() -> Self {
|
|
|
|
Self {
|
|
|
|
commitment: CommitmentLevel::Recent,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-18 10:38:54 -08:00
|
|
|
pub fn max() -> Self {
|
|
|
|
Self {
|
|
|
|
commitment: CommitmentLevel::Max,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-29 21:55:33 -07:00
|
|
|
pub fn root() -> Self {
|
|
|
|
Self {
|
|
|
|
commitment: CommitmentLevel::Root,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-18 11:49:01 -07:00
|
|
|
pub fn single() -> Self {
|
|
|
|
Self {
|
|
|
|
commitment: CommitmentLevel::Single,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-22 12:55:17 -07:00
|
|
|
pub fn single_gossip() -> Self {
|
|
|
|
Self {
|
|
|
|
commitment: CommitmentLevel::SingleGossip,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-03 16:53:30 -08:00
|
|
|
pub fn ok(self) -> Option<Self> {
|
|
|
|
if self == Self::default() {
|
2019-11-06 13:15:00 -08:00
|
|
|
None
|
|
|
|
} else {
|
2020-03-03 16:53:30 -08:00
|
|
|
Some(self)
|
2019-11-06 13:15:00 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-22 12:55:17 -07:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
2019-11-06 13:15:00 -08:00
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub enum CommitmentLevel {
|
|
|
|
Max,
|
|
|
|
Recent,
|
2020-04-29 21:55:33 -07:00
|
|
|
Root,
|
2020-05-18 11:49:01 -07:00
|
|
|
Single,
|
2020-05-22 12:55:17 -07:00
|
|
|
SingleGossip,
|
2019-11-06 13:15:00 -08:00
|
|
|
}
|