Skip to content

Commit

Permalink
grin v5.3 (0135) more chrono warnings, update cursive lib (mimblewimb…
Browse files Browse the repository at this point in the history
  • Loading branch information
bayk committed Jun 21, 2024
1 parent 0e41374 commit 3f25b81
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions core/src/core/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl Default for BlockHeader {
BlockHeader {
version: HeaderVersion(1),
height: 0,
timestamp: DateTime::<Utc>::from_utc(
timestamp: DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
Utc,
),
Expand Down Expand Up @@ -325,7 +325,7 @@ fn read_block_header<R: Reader>(reader: &mut R) -> Result<BlockHeader, ser::Erro
Ok(BlockHeader {
version,
height,
timestamp: DateTime::<Utc>::from_utc(ts.unwrap(), Utc),
timestamp: DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc),
prev_hash,
prev_root,
output_root,
Expand Down Expand Up @@ -702,7 +702,7 @@ impl Block {
return Err(Error::Other("Converting Utc::now() into timestamp".into()));
}

let timestamp = DateTime::<Utc>::from_utc(ts.unwrap(), Utc);
let timestamp = DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc);
// Now build the block with all the above information.
// Note: We have not validated the block here.
// Caller must validate the block as necessary.
Expand Down
6 changes: 4 additions & 2 deletions core/src/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ pub fn pow_size(
// and if we're back where we started, update the time (changes the hash as
// well)
if bh.pow.nonce == start_nonce {
bh.timestamp =
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp_opt(0, 0).unwrap(), Utc);
bh.timestamp = DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
Utc,
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion servers/src/mining/mine_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn build_block(
if ts.is_none() {
return Err(Error::General("Utc::now into timestamp".into()));
}
b.header.timestamp = DateTime::<Utc>::from_utc(ts.unwrap(), Utc);
b.header.timestamp = DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc);

debug!(
"Built new block with {} inputs and {} outputs, block difficulty: {}, cumulative difficulty {}",
Expand Down
4 changes: 2 additions & 2 deletions src/bin/tui/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl TableViewItem<StratumWorkerColumn> for WorkerStats {
0,
)
.unwrap_or_default();
let datetime: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
let datetime: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive_datetime, Utc);

match column {
StratumWorkerColumn::Id => self.id.clone(),
Expand Down Expand Up @@ -130,7 +130,7 @@ impl TableViewItem<DiffColumn> for DiffBlock {
fn to_column(&self, column: DiffColumn) -> String {
let naive_datetime =
NaiveDateTime::from_timestamp_opt(self.time as i64, 0).unwrap_or_default();
let datetime: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
let datetime: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive_datetime, Utc);

match column {
DiffColumn::Height => self.block_height.to_string(),
Expand Down
7 changes: 5 additions & 2 deletions src/bin/tui/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ impl TUIStatusView {
SyncStatus::TxHashsetDownload(stat) => {
if stat.total_size > 0 {
let percent = stat.downloaded_size * 100 / stat.total_size;
let start = stat.prev_update_time.timestamp_nanos();
let fin = Utc::now().timestamp_nanos();
let start = stat
.prev_update_time
.timestamp_nanos_opt()
.unwrap_or_default();
let fin = Utc::now().timestamp_nanos_opt().unwrap_or_default();
let dur_ms = (fin - start) as f64 * NANO_TO_MILLIS;

Cow::Owned(format!("Sync step 2/7: Downloading {}(MB) chain state for state sync: {}% at {:.1?}(kB/s)",
Expand Down

0 comments on commit 3f25b81

Please sign in to comment.