From 7f3e29e81f18ee10085b600f1f9dc8e0a2560950 Mon Sep 17 00:00:00 2001 From: Arun Koshy <97870774+arun-koshy@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:00:43 -0800 Subject: [PATCH] readd metadata default (#6654) --- narwhal/types/src/primary.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/narwhal/types/src/primary.rs b/narwhal/types/src/primary.rs index 9f518a8385ed3..75835c0a9684e 100644 --- a/narwhal/types/src/primary.rs +++ b/narwhal/types/src/primary.rs @@ -68,13 +68,19 @@ pub fn now() -> TimestampMs { // for NON CRITICAL purposes only. For example should not be used // for any processes that are part of our protocol that can affect // safety or liveness. -#[derive(Clone, Default, Serialize, Deserialize, Debug, PartialEq, Eq, Arbitrary, MallocSizeOf)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Arbitrary, MallocSizeOf)] pub struct Metadata { // timestamp of when the entity created. This is generated // by the node which creates the entity. pub created_at: TimestampMs, } +impl Default for Metadata { + fn default() -> Self { + Metadata { created_at: now() } + } +} + pub type Transaction = Vec; #[derive(Clone, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Arbitrary)] pub struct Batch { @@ -86,7 +92,7 @@ impl Batch { pub fn new(transactions: Vec) -> Self { Batch { transactions, - metadata: Metadata { created_at: now() }, + metadata: Metadata::default(), } } }