Skip to content

Commit

Permalink
wallclock as ms
Browse files Browse the repository at this point in the history
  • Loading branch information
ebatsell committed Dec 19, 2023
1 parent 05635a0 commit 60bb7b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ pub fn handler(ctx: Context<CopyGossipContactInfo>) -> Result<()> {
return Err(ValidatorHistoryError::GossipDataInvalid.into());
}

// Timestamp can't be too far in the future or this upload will be stuck. Allows 10 minutes of buffer
if last_signed_ts
// Timestamp can't be too far in the future or this upload will be stuck. Allows 10 minutes of buffer.
// last_signed_ts is in ms, clock.unix_timestamp is in seconds
if last_signed_ts / 1000
> clock
.unix_timestamp
.checked_add(600)
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test_gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ async fn test_gossip_timestamps() {
};

let clock: Clock = banks_client.get_sysvar().await.unwrap();
let wallclock = clock.unix_timestamp as u64;
let wallclock = clock.unix_timestamp as u64 * 1000;
let mut contact_info = ContactInfo::new(fixture.identity_keypair.pubkey(), wallclock, 0);
let ipv4 = Ipv4Addr::new(1, 2, 3, 4);
let ip = IpAddr::V4(ipv4);
Expand Down Expand Up @@ -395,7 +395,7 @@ async fn test_gossip_timestamps() {
.await;

// ContactInfo with 11 minutes in the future wallclock - will fail
contact_info.set_wallclock(wallclock + 11 * 60);
contact_info.set_wallclock(wallclock + 11 * 60 * 1000);
let crds_data = CrdsData::ContactInfo(contact_info.clone());
let transaction = create_gossip_tx(&fixture, &crds_data);

Expand Down

0 comments on commit 60bb7b9

Please sign in to comment.