Add `CommitEvent` struct
Add the `CommitEvent` struct, which will be used as a generic way to
represent a commit and its associated state changes from some arbitrary
source.
@@ -38,6 +38,26 @@ const TRACK_AND_TRACE_PROPERTY: &str = "a43b46ea";
const TRACK_AND_TRACE_PROPOSAL: &str = "a43b46aa";
const TRACK_AND_TRACE_RECORD: &str = "a43b46ec";
+/// A notification that some source has committed a set of changes to state
+pub struct CommitEvent {
+ /// An identifier for specifying where the event came from
+ pub source: String,
+ /// An identifier that is unique among events from the source
+ pub id: String,
+ /// May be used to provide ordering of commits from the source. If `None`, ordering is not
+ /// explicitly provided, so it must be inferred from the order in which events are received.
+ pub height: Option<u64>,
+ /// All state changes that are included in the commit
+ pub state_changes: Vec<StateChange>,
+}
+
+/// A change that has been applied to state, represented in terms of a key/value pair
+#[derive(Eq, PartialEq)]
+pub enum StateChange {
+ Set { key: String, value: Vec<u8> },
+ Delete { key: String },
+}
+
pub trait EventHandler: Send {
fn handle_events(&self, events: &[Event]) -> Result<(), EventError>;
}
