-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove separate validation array (#1522)
Right now, we have two types with the same shape: ```rust /// Results of validating a single block #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub(crate) enum Validation { /// The block has no hash / context and is empty Empty, /// For an unencrypted block, the result is the hash Unencrypted(u64), /// For an encrypted block, the result is the tag + nonce Encrypted(crucible_protocol::EncryptionContext), } ``` ```rust #[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)] pub enum ReadBlockContext { Empty, Encrypted { ctx: EncryptionContext }, Unencrypted { hash: u64 }, } ``` The `DownstairsIO` stores both of these types: ```rust struct DownstairsIO { // other members elided data: Option<RawReadResponse>, // contains blocks: Vec<ReadBlockContext> pub hashes: Vec<Validation>, } ``` By the time we write to `data`, the block contexts have _already_ been validated, so storing them again in `hashes` adds unnecessary duplication (and they're guaranteed to be the same). This PR removes the duplicate `Validation` hashes, using the `RawReadResponse::blocks` member instead. There are small changes to `GuestBlockRes::transfer_and_notify` and `Buffer::write_read_response`, because we can't take the entire `Option<RawReadResponse>`; instead, we pass the `&mut BytesMut` separately, so it can be sent back to the host.
- Loading branch information
Showing
8 changed files
with
91 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.