nonempty 0.7

We can now correctly measure the heap-allocated memory used by a bundle.
This commit is contained in:
Jack Grigg 2021-06-23 12:00:56 +01:00
parent 1f861423c2
commit 3badd42d15
2 changed files with 2 additions and 4 deletions

View File

@ -31,7 +31,7 @@ lazy_static = "1"
pasta_curves = "0.1"
proptest = { version = "1.0.0", optional = true }
rand = "0.8"
nonempty = "0.6"
nonempty = "0.7"
serde = { version = "1.0", features = ["derive"] }
subtle = "2.3"
zcash_note_encryption = "0.0"

View File

@ -360,9 +360,7 @@ impl<V> Bundle<Authorized, V> {
/// Returns the amount of heap-allocated memory used by this bundle.
pub fn dynamic_usage(&self) -> usize {
// NonEmpty<T> stores its head element separately from its tail Vec<T>.
// TODO: This underestimates the dynamic usage; switch to NonEmpty::capacity once
// https://github.com/cloudhead/nonempty/issues/33 is closed.
(self.actions.len() - 1) * mem::size_of::<Action<redpallas::Signature<SpendAuth>>>()
(self.actions.capacity() - 1) * mem::size_of::<Action<redpallas::Signature<SpendAuth>>>()
+ self.authorization.proof.dynamic_usage()
}