Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ExpiringKey #215

Merged
merged 4 commits into from
Mar 6, 2023
Merged

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Mar 5, 2023

Relates to: #171

The ExpiringKey::valid_until (duration) does not need to be optional anymore since we introduced the KeyId struct.

Besides, after renaming the Key struct to ExpiringKey, there is no longer a conflict with the KeyId, so we can use the name Key for the KeyId again.

Before:

pub struct ExpiringKey {
    pub id: KeyId,
    pub valid_until: Option<DurationSinceUnixEpoch>,
}

After:

pub struct ExpiringKey {
    pub key: Key,
    pub valid_until: DurationSinceUnixEpoch,
}

After this refactoring, you can read the code like this:

"An ExpiringKey is a Key valid until a date expressed in a duration from the Unix epoch (timestamp)".

@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label Mar 5, 2023
Adter intruducing the `KeyId` we no longer needed to have keys with no
expiration date. A key without an expiration date is a `KeyId`.

So all `ExpiraingKeys` have an expiration date.
There is no longer a clonflict with the `ExpiringKey` strcut that was
also called `Key`.
@josecelano josecelano force-pushed the refactor-expiring-key branch from c46d255 to 0ee5a51 Compare March 5, 2023 12:19
@josecelano josecelano marked this pull request as ready for review March 5, 2023 12:20
@josecelano
Copy link
Member Author

Hi @da2ce7 @WarmBeer, this is ready to review. It's just a minor refactoring.

…r key_id

to `Key` and `key`. removing the `Id` and `id`, since the `KeyId` struct
was renamed to `Key`.
@josecelano josecelano force-pushed the refactor-expiring-key branch from 0ee5a51 to af038de Compare March 5, 2023 12:32
Copy link
Contributor

@da2ce7 da2ce7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@josecelano josecelano merged commit 6d83d9b into torrust:develop Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup / Refactoring Tidying and Making Neat
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants