Additional internal pdu getters.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-01 21:46:30 +00:00
parent 2ead282bec
commit a2b4c07cf7

View File

@@ -87,14 +87,21 @@ impl Data {
.map(|pdu_id| pdu_id.pdu_count())
}
/// Returns the json of a pdu.
pub(super) async fn get_outlier_pdu_json(
&self,
event_id: &EventId,
) -> Result<CanonicalJsonObject> {
self.eventid_outlierpdu
.get(event_id)
.await
.deserialized()
}
/// Returns the json of a pdu.
pub(super) async fn get_pdu_json(&self, event_id: &EventId) -> Result<CanonicalJsonObject> {
let accepted = self.get_non_outlier_pdu_json(event_id).boxed();
let outlier = self
.eventid_outlierpdu
.get(event_id)
.map(Deserialized::deserialized)
.boxed();
let outlier = self.get_outlier_pdu_json(event_id).boxed();
select_ok([accepted, outlier]).await.map(at!(0))
}
@@ -133,16 +140,22 @@ impl Data {
self.pduid_pdu.exists(&pduid).await
}
/// Returns the pdu.
///
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
pub(super) async fn get_outlier_pdu(&self, event_id: &EventId) -> Result<PduEvent> {
self.eventid_outlierpdu
.get(event_id)
.await
.deserialized()
}
/// Returns the pdu.
///
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
pub(super) async fn get_pdu(&self, event_id: &EventId) -> Result<PduEvent> {
let accepted = self.get_non_outlier_pdu(event_id).boxed();
let outlier = self
.eventid_outlierpdu
.get(event_id)
.map(Deserialized::deserialized)
.boxed();
let outlier = self.get_outlier_pdu(event_id).boxed();
select_ok([accepted, outlier]).await.map(at!(0))
}