From 9b79798e56c772fe338815d97e7d423e4e920806 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 6 Apr 2020 14:53:34 +0200 Subject: [PATCH] start work on signing --- src/data.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/data.rs b/src/data.rs index 2aa003a5..08e5e59a 100644 --- a/src/data.rs +++ b/src/data.rs @@ -457,6 +457,9 @@ impl Data { )) .expect("ruma's reference hashes are correct"); + let mut pdu_json = serde_json::to_value(pdu).unwrap(); + ruma_signatures::hash_and_sign_event(self.hostname(), self.keypair(), &mut pdu_json); + self.pdu_leaves_replace(&room_id, &pdu.event_id); // The new value will need a new index. We store the last used index in 'n' @@ -478,9 +481,10 @@ impl Data { pdu_id.push(0xff); // Add delimiter so we don't find rooms starting with the same id pdu_id.extend_from_slice(&index.to_be_bytes()); - let pdu_json = serde_json::to_string(&pdu).unwrap(); - - self.db.pduid_pdu.insert(&pdu_id, &*pdu_json).unwrap(); + self.db + .pduid_pdu + .insert(&pdu_id, &*serde_json::to_string(&pdu_json).unwrap()) + .unwrap(); self.db .eventid_pduid