Simplify Pdu Hashes struct.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -458,7 +458,7 @@ async fn handle_left_room(
|
||||
depth: uint!(1),
|
||||
auth_events: vec![],
|
||||
redacts: None,
|
||||
hashes: EventHash { sha256: String::new() },
|
||||
hashes: EventHash::default(),
|
||||
signatures: None,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
mod builder;
|
||||
mod count;
|
||||
mod hashes;
|
||||
mod id;
|
||||
mod raw_id;
|
||||
mod redact;
|
||||
@@ -20,6 +21,7 @@ pub use self::{
|
||||
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
||||
builder::{Builder, Builder as PduBuilder},
|
||||
count::Count,
|
||||
hashes::EventHashes as EventHash,
|
||||
id::{ShortId, *},
|
||||
raw_id::*,
|
||||
};
|
||||
@@ -67,13 +69,6 @@ pub struct Pdu {
|
||||
pub signatures: Option<Box<RawJsonValue>>,
|
||||
}
|
||||
|
||||
/// Content hashes of a PDU.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct EventHash {
|
||||
/// The SHA-256 hash.
|
||||
pub sha256: String,
|
||||
}
|
||||
|
||||
impl Pdu {
|
||||
pub fn from_id_val(event_id: &EventId, mut json: CanonicalJsonObject) -> Result<Self> {
|
||||
let event_id = CanonicalJsonValue::String(event_id.into());
|
||||
|
||||
12
src/core/matrix/pdu/hashes.rs
Normal file
12
src/core/matrix/pdu/hashes.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::arrayvec::ArrayString;
|
||||
|
||||
/// Content hashes of a PDU.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct EventHashes {
|
||||
/// The SHA-256 hash.
|
||||
pub sha256: ArrayString<SHA256_LEN>,
|
||||
}
|
||||
|
||||
const SHA256_LEN: usize = 43;
|
||||
@@ -418,7 +418,7 @@ where
|
||||
auth_events,
|
||||
prev_events,
|
||||
depth: uint!(0),
|
||||
hashes: EventHash { sha256: String::new() },
|
||||
hashes: EventHash::default(),
|
||||
signatures: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ pub(crate) fn to_init_pdu_event(
|
||||
auth_events: vec![],
|
||||
prev_events: vec![],
|
||||
depth: uint!(0),
|
||||
hashes: EventHash { sha256: "".to_owned() },
|
||||
hashes: EventHash::default(),
|
||||
signatures: None,
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ where
|
||||
auth_events,
|
||||
prev_events,
|
||||
depth: uint!(0),
|
||||
hashes: EventHash { sha256: "".to_owned() },
|
||||
hashes: EventHash::default(),
|
||||
signatures: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ pub async fn create_hash_and_sign_event(
|
||||
depth,
|
||||
redacts,
|
||||
unsigned,
|
||||
hashes: EventHash { sha256: "aaa".to_owned() },
|
||||
hashes: EventHash::default(),
|
||||
signatures: None,
|
||||
prev_events,
|
||||
auth_events: auth_events
|
||||
|
||||
Reference in New Issue
Block a user