Skip to content

Commit 9ad810d

Browse files
committed
refactor: update timestamp() to timestamp_ns()
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 07fa2d8 commit 9ad810d

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

tap_core/src/manager/adapters/receipt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ pub fn safe_truncate_receipts<T: ReceiptState, R: WithValueAndTimestamp>(
113113
return;
114114
}
115115

116-
receipts.sort_unstable_by_key(|rx_receipt| rx_receipt.signed_receipt().timestamp());
116+
receipts.sort_unstable_by_key(|rx_receipt| rx_receipt.signed_receipt().timestamp_ns());
117117

118118
// This one will be the last timestamp in `receipts` after naive truncation
119-
let last_timestamp = receipts[limit as usize - 1].signed_receipt().timestamp();
119+
let last_timestamp = receipts[limit as usize - 1].signed_receipt().timestamp_ns();
120120
// This one is the timestamp that comes just after the one above
121-
let after_last_timestamp = receipts[limit as usize].signed_receipt().timestamp();
121+
let after_last_timestamp = receipts[limit as usize].signed_receipt().timestamp_ns();
122122

123123
receipts.truncate(limit as usize);
124124

125125
if last_timestamp == after_last_timestamp {
126126
// If the last timestamp is the same as the one that came after it, we need to
127127
// remove all the receipts with the same timestamp as the last one, because
128128
// otherwise we would leave behind part of the receipts for that timestamp.
129-
receipts.retain(|rx_receipt| rx_receipt.signed_receipt().timestamp() != last_timestamp);
129+
receipts.retain(|rx_receipt| rx_receipt.signed_receipt().timestamp_ns() != last_timestamp);
130130
}
131131
}

tap_core/src/manager/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub use tap_manager::Manager;
9292

9393
pub trait WithValueAndTimestamp {
9494
fn value(&self) -> u128;
95-
fn timestamp(&self) -> u64;
95+
fn timestamp_ns(&self) -> u64;
9696
}
9797

9898
pub trait WithUniqueId {

tap_core/src/manager/tap_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ where
202202
let previous_rav = self.get_previous_rav().await?;
203203
let min_timestamp_ns = previous_rav
204204
.as_ref()
205-
.map(|rav| rav.message.timestamp() + 1)
205+
.map(|rav| rav.message.timestamp_ns() + 1)
206206
.unwrap_or(0);
207207

208208
let (valid_receipts, invalid_receipts) = self
@@ -239,7 +239,7 @@ where
239239
match self.get_previous_rav().await? {
240240
Some(last_rav) => {
241241
self.context
242-
.remove_receipts_in_timestamp_range(..=last_rav.message.timestamp())
242+
.remove_receipts_in_timestamp_range(..=last_rav.message.timestamp_ns())
243243
.await
244244
.map_err(|err| Error::AdapterError {
245245
source_error: anyhow::Error::new(err),

tap_core/src/rav.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl WithValueAndTimestamp for ReceiptAggregateVoucher {
9393
self.valueAggregate
9494
}
9595

96-
fn timestamp(&self) -> u64 {
96+
fn timestamp_ns(&self) -> u64 {
9797
self.timestampNs
9898
}
9999
}

tap_core/src/receipt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ where
162162
) {
163163
let (mut checking, mut failed) = (vec![], vec![]);
164164
for receipt in receipts.into_iter() {
165-
let receipt_timestamp_ns = receipt.signed_receipt().timestamp();
165+
let receipt_timestamp_ns = receipt.signed_receipt().timestamp_ns();
166166
let min_timestamp_ns = self.0;
167167
if receipt_timestamp_ns >= min_timestamp_ns {
168168
checking.push(receipt);

tap_core/src/receipt/receipt_sol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl WithValueAndTimestamp for Receipt {
3535
self.value
3636
}
3737

38-
fn timestamp(&self) -> u64 {
38+
fn timestamp_ns(&self) -> u64 {
3939
self.timestamp_ns
4040
}
4141
}

tap_core/src/signed_message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ where
5555
self.message.value()
5656
}
5757

58-
fn timestamp(&self) -> u64 {
59-
self.message.timestamp()
58+
fn timestamp_ns(&self) -> u64 {
59+
self.message.timestamp_ns()
6060
}
6161
}
6262

0 commit comments

Comments
 (0)