diff options
Diffstat (limited to 'tvix/store/src/proto/mod.rs')
-rw-r--r-- | tvix/store/src/proto/mod.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index 528d0fb061fd..4db0b9731edc 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -17,6 +17,8 @@ pub use grpc_blobservice_wrapper::GRPCBlobServiceWrapper; pub use grpc_directoryservice_wrapper::GRPCDirectoryServiceWrapper; pub use grpc_pathinfoservice_wrapper::GRPCPathInfoServiceWrapper; +use crate::B3Digest; + tonic::include_proto!("tvix.store.v1"); #[cfg(feature = "reflection")] @@ -238,10 +240,15 @@ impl Directory { /// Calculates the digest of a Directory, which is the blake3 hash of a /// Directory protobuf message, serialized in protobuf canonical form. - pub fn digest(&self) -> [u8; 32] { + pub fn digest(&self) -> B3Digest { let mut hasher = blake3::Hasher::new(); - *hasher.update(&self.encode_to_vec()).finalize().as_bytes() + let vec = hasher + .update(&self.encode_to_vec()) + .finalize() + .as_bytes() + .to_vec(); + B3Digest::from_vec(vec).unwrap() } /// validate checks the directory for invalid data, such as: |