2021-01-14 21:32:22 -05:00
|
|
|
/// Returns the pdu from the outlier tree.
|
|
|
|
|
pub fn get_pdu_outlier(&self, event_id: &EventId) -> Result<Option<PduEvent>> {
|
2021-03-13 16:30:12 +01:00
|
|
|
self.eventid_outlierpdu
|
2021-02-01 12:44:30 -05:00
|
|
|
.get(event_id.as_bytes())?
|
|
|
|
|
.map_or(Ok(None), |pdu| {
|
2021-01-29 21:45:33 -05:00
|
|
|
serde_json::from_slice(&pdu).map_err(|_| Error::bad_database("Invalid PDU in db."))
|
2021-01-14 21:32:22 -05:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 20:00:01 -05:00
|
|
|
/// Append the PDU as an outlier.
|
|
|
|
|
///
|
|
|
|
|
/// Any event given to this will be processed (state-res) on another thread.
|
2021-07-29 08:36:01 +02:00
|
|
|
#[tracing::instrument(skip(self, pdu))]
|
2021-04-16 18:18:29 +02:00
|
|
|
pub fn add_pdu_outlier(&self, event_id: &EventId, pdu: &CanonicalJsonObject) -> Result<()> {
|
2021-03-13 16:30:12 +01:00
|
|
|
self.eventid_outlierpdu.insert(
|
2021-09-13 19:45:56 +02:00
|
|
|
event_id.as_bytes(),
|
2021-06-08 18:10:00 +02:00
|
|
|
&serde_json::to_vec(&pdu).expect("CanonicalJsonObject is valid"),
|
2021-08-28 11:39:33 +02:00
|
|
|
)
|
|
|
|
|
}
|
2021-01-29 21:45:33 -05:00
|
|
|
|