From d3b7eecaed930bf5385ad40bff1ca997ed3f3473 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Thu, 16 May 2024 00:30:33 -0700 Subject: [PATCH] swap commented code for prose about "ownership" This more clearly communicates the purpose of the comments, and thus also the order of fields in the struct. --- src/database.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/database.rs b/src/database.rs index faddb9f9..5b14ebe6 100644 --- a/src/database.rs +++ b/src/database.rs @@ -32,11 +32,11 @@ use tracing::{debug, error, info, warn}; pub(crate) struct KeyValueDatabase { db: Arc, - //pub(crate) globals: globals::Globals, + // Trees "owned" by `self::key_value::globals` pub(super) global: Arc, pub(super) server_signingkeys: Arc, - //pub(crate) users: users::Users, + // Trees "owned" by `self::key_value::users` pub(super) userid_password: Arc, pub(super) userid_displayname: Arc, pub(super) userid_avatarurl: Arc, @@ -58,12 +58,12 @@ pub(crate) struct KeyValueDatabase { pub(super) todeviceid_events: Arc, // ToDeviceId = UserId + DeviceId + Count - //pub(crate) uiaa: uiaa::Uiaa, + // Trees "owned" by `self::key_value::uiaa` pub(super) userdevicesessionid_uiaainfo: Arc, // User-interactive authentication pub(super) userdevicesessionid_uiaarequest: RwLock>, - //pub(crate) edus: RoomEdus, + // Trees "owned" by `self::key_value::rooms::edus` pub(super) readreceiptid_readreceipt: Arc, // ReadReceiptId = RoomId + Count + UserId pub(super) roomuserid_privateread: Arc, // RoomUserId = Room + User, PrivateRead = Count pub(super) roomuserid_lastprivatereadupdate: Arc, // LastPrivateReadUpdate = Count @@ -74,7 +74,7 @@ pub(crate) struct KeyValueDatabase { #[allow(dead_code)] pub(super) userid_lastpresenceupdate: Arc, // LastPresenceUpdate = Count - //pub(crate) rooms: rooms::Rooms, + // Trees "owned" by `self::key_value::rooms` pub(super) pduid_pdu: Arc, // PduId = ShortRoomId + Count pub(super) eventid_pduid: Arc, pub(super) roomid_pduleaves: Arc, @@ -137,30 +137,31 @@ pub(crate) struct KeyValueDatabase { /// RoomId + EventId -> Parent PDU EventId. pub(super) referencedevents: Arc, - //pub(crate) account_data: account_data::AccountData, + // Trees "owned" by `self::key_value::account_data` pub(super) roomuserdataid_accountdata: Arc, // RoomUserDataId = Room + User + Count + Type pub(super) roomusertype_roomuserdataid: Arc, // RoomUserType = Room + User + Type - //pub(crate) media: media::Media, + // Trees "owned" by `self::key_value::media` pub(super) mediaid_file: Arc, // MediaId = MXC + WidthHeight + ContentDisposition + ContentType - //pub(crate) key_backups: key_backups::KeyBackups, + // Trees "owned" by `self::key_value::key_backups` pub(super) backupid_algorithm: Arc, // BackupId = UserId + Version(Count) pub(super) backupid_etag: Arc, // BackupId = UserId + Version(Count) pub(super) backupkeyid_backup: Arc, // BackupKeyId = UserId + Version + RoomId + SessionId - //pub(crate) transaction_ids: transaction_ids::TransactionIds, + // Trees "owned" by `self::key_value::transaction_ids` pub(super) userdevicetxnid_response: Arc, // Response can be empty (/sendToDevice) or the event id (/send) - //pub(crate) sending: sending::Sending, + // Trees "owned" by `self::key_value::sending` pub(super) servername_educount: Arc, // EduCount: Count of last EDU sync pub(super) servernameevent_data: Arc, // ServernameEvent = (+ / $)SenderKey / ServerName / UserId + PduId / Id (for edus), Data = EDU content pub(super) servercurrentevent_data: Arc, // ServerCurrentEvents = (+ / $)ServerName / UserId + PduId / Id (for edus), Data = EDU content - //pub(crate) appservice: appservice::Appservice, + // Trees "owned" by `self::key_value::appservice` pub(super) id_appserviceregistrations: Arc, - //pub(crate) pusher: pusher::PushData, + // Trees "owned" by `self::key_value::pusher` pub(super) senderkey_pusher: Arc, + // Uncategorized trees pub(super) pdu_cache: Mutex>>, pub(super) shorteventid_cache: Mutex>>, pub(super) auth_chain_cache: Mutex, Arc>>>,