Skip to content

Commit

Permalink
readd metadata default (MystenLabs#6654)
Browse files Browse the repository at this point in the history
  • Loading branch information
arun-koshy authored Dec 8, 2022
1 parent 74f36c1 commit 7f3e29e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions narwhal/types/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>;
#[derive(Clone, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Arbitrary)]
pub struct Batch {
Expand All @@ -86,7 +92,7 @@ impl Batch {
pub fn new(transactions: Vec<Transaction>) -> Self {
Batch {
transactions,
metadata: Metadata { created_at: now() },
metadata: Metadata::default(),
}
}
}
Expand Down

0 comments on commit 7f3e29e

Please sign in to comment.