Skip to content
Snippets Groups Projects

guardmgr: Use a better persistent data format

Merged Nick Mathewson requested to merge nickm/arti:ticket_176_v2 into main
2 unresolved threads

Previously we stored only one guard sample, in a state file called "default_guards". That's not future-proof, since we want to have multiple samples in the future. (guard-spec.txt specifies separate samples for highly restrictive filters, and for bridge usage.)

This patch changes our behavior so that we can store multiple samples in a new "guards" file.

I had thought about automatically migrating from the previous file format and location, but I don't think that's necessary given our current (lack of) stability guarantees.

Closes #176 (closed).

Edited by Nick Mathewson

Merge request reports

Approval is optional

Merged by Nick MathewsonNick Mathewson 3 years ago (Jan 11, 2022 5:52pm UTC)

Merge details

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Ian Jackson
  • Ian Jackson
  • Ian Jackson
    Ian Jackson @Diziet started a thread on an outdated change in commit 4a3e41d1
  • 233 228 waiting: Vec<PendingRequest>,
    234 229
    235 230 /// Location in which to store persistent state.
    231 storage: DynStorageHandle<GuardMgrPersistState>,
    232 }
    233
    234 /// Persistent state for a guard manager, as serialized to disk.
    235 #[derive(Debug, Default, Clone, Serialize, Deserialize)]
    236 struct GuardMgrPersistState {
    • Comment on lines +234 to +236

      I think this struct is misnamed and miscommented. It contains both persistent and ephemeral state, because, eventually, Guard does.

      For example, observe that later you have

          /// Update all non-persistent state for the guards in this object with the state in `other`.
          fn copy_status_from(&mut self, other: &GuardMgrPersistState) {
              self.default.copy_status_from(&other.default);

      which is a very strange thing to have written: "update all the non-persistent state in the persistent state".

      If you agree and rename this, it might be worth looking at the next nearby the uses, as confusing wording appears elsewhere too eg at least in the state: GuardMgrPersistState field of GuardMgrInner.

    • Hm, any ideas for another name? GuardSamples? GuardSets?

    • GuardSets sounds good to me. AIUI this is supposed to be going-to-contain the multiple guard sets for different filterings.

      For the variable name I suggest maybe guards (although that results in guards.access_guards() giving GuardSet) or gsets but I don't have a very strong opinion.

    • Nick Mathewson changed this line in version 3 of the diff

      changed this line in version 3 of the diff

    • Please register or sign in to reply
  • Ian Jackson
    Ian Jackson @Diziet started a thread on an outdated change in commit 4a3e41d1
  • 287 307 /// files. If we have the lock, we only want to save.
    288 308 pub fn reload_persistent_state(&self) -> Result<(), GuardMgrError> {
    289 309 let mut inner = self.inner.lock().expect("Poisoned lock");
    290 if let Some(new_guards) = inner.default_storage.load()? {
    310 if let Some(new_state) = inner.storage.load()? {
  • Ian Jackson
  • Nick Mathewson added 2 commits

    added 2 commits

    • d26e10bf - fixup! guardmgr: Use a better persistent data format
    • 7a32119b - fixup! guardmgr: Use a better persistent data format

    Compare with previous version

  • Nick Mathewson marked this merge request as draft from nickm/arti@d26e10bf

    marked this merge request as draft from nickm/arti@d26e10bf

  • mentioned in issue #282 (closed)

  • Nick Mathewson added 1 commit

    added 1 commit

    • 76d9ed24 - fixup! guardmgr: Use a better persistent data format

    Compare with previous version

  • Nick Mathewson added 15 commits

    added 15 commits

    Compare with previous version

  • Nick Mathewson marked this merge request as ready

    marked this merge request as ready

  • Nick Mathewson enabled an automatic merge when the pipeline for b89ce484 succeeds

    enabled an automatic merge when the pipeline for b89ce484 succeeds

  • Nick Mathewson mentioned in commit 08d3ed97

    mentioned in commit 08d3ed97

  • Please register or sign in to reply
    Loading