Skip to content

Commit feafbda

Browse files
committed
refactor(twap): change window_seconds type from i64 to u64 in get_twaps_with_update_data function
1 parent 12b8bad commit feafbda

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

apps/hermes/server/src/api/rest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ mod tests {
201201
async fn get_twaps_with_update_data(
202202
&self,
203203
_price_ids: &[PriceIdentifier],
204-
_window_seconds: i64,
204+
_window_seconds: u64,
205205
_end_time: RequestTime,
206206
) -> Result<TwapsWithUpdateData> {
207207
unimplemented!("Not needed for this test")

apps/hermes/server/src/api/rest/v2/latest_twaps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ where
109109
let twaps_with_update_data = Aggregates::get_twaps_with_update_data(
110110
&*state.state,
111111
&price_ids,
112-
path_params.window_seconds as i64,
112+
path_params.window_seconds,
113113
RequestTime::LatestTimeEarliestSlot,
114114
)
115115
.await

apps/hermes/server/src/state/aggregate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ where
244244
async fn get_twaps_with_update_data(
245245
&self,
246246
price_ids: &[PriceIdentifier],
247-
window_seconds: i64,
247+
window_seconds: u64,
248248
end_time: RequestTime,
249249
) -> Result<TwapsWithUpdateData>;
250250
}
@@ -412,7 +412,7 @@ where
412412
async fn get_twaps_with_update_data(
413413
&self,
414414
price_ids: &[PriceIdentifier],
415-
window_seconds: i64,
415+
window_seconds: u64,
416416
end_time: RequestTime,
417417
) -> Result<TwapsWithUpdateData> {
418418
match get_verified_twaps_with_update_data(self, price_ids, window_seconds, end_time.clone())
@@ -634,7 +634,7 @@ where
634634
async fn get_verified_twaps_with_update_data<S>(
635635
state: &S,
636636
price_ids: &[PriceIdentifier],
637-
window_seconds: i64,
637+
window_seconds: u64,
638638
end_time: RequestTime,
639639
) -> Result<TwapsWithUpdateData>
640640
where
@@ -663,7 +663,7 @@ where
663663
));
664664
} else {
665665
// Use the publish time from the first end message
666-
end_messages[0].message.publish_time() - window_seconds
666+
end_messages[0].message.publish_time() - window_seconds as i64
667667
};
668668
let start_time = RequestTime::FirstAfter(start_timestamp);
669669

apps/hermes/server/src/state/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ async fn retrieve_message_state(
292292
let mut latest_entry_with_earliest_slot = last_entry;
293293

294294
// Walk backwards through the sorted entries rather than use `range` since we will only
295-
// have 1-2 entries that have the same publish_time.
295+
// have a couple entries that have the same publish_time.
296296
// We have acquired the RwLock via read() above, so we should be safe to reenter the cache here.
297297
for (k, v) in key_cache.iter().rev() {
298298
if k.publish_time < latest_publish_time {

0 commit comments

Comments
 (0)