-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: create event for when app parameters change
It's unfortunate that we can't put this somewhere else to avoid including cnidarium, and thus rocksdb, when you just want to read the event. A refactoring of the app crate to allow consuming it "as a component" can be added later.
- Loading branch information
1 parent
88a021e
commit 3ffe595
Showing
7 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use anyhow::{anyhow, Context}; | ||
use penumbra_proto::{penumbra::core::app::v1 as pb, DomainType}; | ||
use prost::Name as _; | ||
|
||
use crate::params::AppParameters; | ||
|
||
#[derive(Clone, Debug)] | ||
struct EventAppParametersChange { | ||
new_parameters: AppParameters, | ||
} | ||
|
||
impl TryFrom<pb::EventAppParametersChange> for EventAppParametersChange { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: pb::EventAppParametersChange) -> Result<Self, Self::Error> { | ||
fn inner(value: pb::EventAppParametersChange) -> anyhow::Result<EventAppParametersChange> { | ||
Ok(EventAppParametersChange { | ||
new_parameters: value | ||
.new_parameters | ||
.ok_or(anyhow!("missing `new_parameters`"))? | ||
.try_into()?, | ||
}) | ||
} | ||
inner(value).context(format!("parsing {}", pb::EventAppParametersChange::NAME)) | ||
} | ||
} | ||
|
||
impl From<EventAppParametersChange> for pb::EventAppParametersChange { | ||
fn from(value: EventAppParametersChange) -> Self { | ||
Self { | ||
new_parameters: Some(value.new_parameters.into()), | ||
} | ||
} | ||
} | ||
|
||
impl DomainType for EventAppParametersChange { | ||
type Proto = pb::EventAppParametersChange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters