Skip to content

Commit c5efaa4

Browse files
authored
more chrono warnings, update cursive lib (mimblewimble#3778)
1 parent d1b7ae5 commit c5efaa4

File tree

12 files changed

+471
-358
lines changed

12 files changed

+471
-358
lines changed

Cargo.lock

+446-335
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ blake2-rfc = "0.2"
2424
chrono = "0.4.11"
2525
clap = { version = "2.33", features = ["yaml"] }
2626
ctrlc = { version = "3.1", features = ["termination"] }
27-
cursive_table_view = "0.13.2"
27+
cursive_table_view = "0.14.0"
2828
humansize = "1.1.0"
2929
serde = "1"
3030
futures = "0.3.19"
@@ -42,7 +42,7 @@ grin_servers = { path = "./servers", version = "5.3.0-alpha.1" }
4242
grin_util = { path = "./util", version = "5.3.0-alpha.1" }
4343

4444
[dependencies.cursive]
45-
version = "0.16"
45+
version = "0.20"
4646
default-features = false
4747
features = ["pancurses-backend"]
4848

core/src/core/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl Default for BlockHeader {
231231
BlockHeader {
232232
version: HeaderVersion(1),
233233
height: 0,
234-
timestamp: DateTime::<Utc>::from_utc(
234+
timestamp: DateTime::from_naive_utc_and_offset(
235235
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
236236
Utc,
237237
),
@@ -313,7 +313,7 @@ fn read_block_header<R: Reader>(reader: &mut R) -> Result<BlockHeader, ser::Erro
313313
Ok(BlockHeader {
314314
version,
315315
height,
316-
timestamp: DateTime::<Utc>::from_utc(ts.unwrap(), Utc),
316+
timestamp: DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc),
317317
prev_hash,
318318
prev_root,
319319
output_root,
@@ -667,7 +667,7 @@ impl Block {
667667
return Err(Error::Other("Converting Utc::now() into timestamp".into()));
668668
}
669669

670-
let timestamp = DateTime::<Utc>::from_utc(ts.unwrap(), Utc);
670+
let timestamp = DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc);
671671
// Now build the block with all the above information.
672672
// Note: We have not validated the block here.
673673
// Caller must validate the block as necessary.

core/src/pow.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ pub fn pow_size(
115115
// and if we're back where we started, update the time (changes the hash as
116116
// well)
117117
if bh.pow.nonce == start_nonce {
118-
bh.timestamp =
119-
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp_opt(0, 0).unwrap(), Utc);
118+
bh.timestamp = DateTime::from_naive_utc_and_offset(
119+
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
120+
Utc,
121+
);
120122
}
121123
}
122124
}

servers/src/mining/mine_block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn build_block(
172172
if ts.is_none() {
173173
return Err(Error::General("Utc::now into timestamp".into()));
174174
}
175-
b.header.timestamp = DateTime::<Utc>::from_utc(ts.unwrap(), Utc);
175+
b.header.timestamp = DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc);
176176

177177
debug!(
178178
"Built new block with {} inputs and {} outputs, block difficulty: {}, cumulative difficulty {}",

src/bin/tui/logs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
use cursive::theme::{BaseColor, Color, ColorStyle};
16-
use cursive::traits::Identifiable;
16+
use cursive::traits::Nameable;
1717
use cursive::view::View;
1818
use cursive::views::ResizedView;
1919
use cursive::{Cursive, Printer};

src/bin/tui/menu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use cursive::align::HAlign;
1818
use cursive::direction::Orientation;
1919
use cursive::event::Key;
20-
use cursive::view::Identifiable;
20+
use cursive::view::Nameable;
2121
use cursive::view::View;
2222
use cursive::views::{
2323
LinearLayout, OnEventView, ResizedView, SelectView, StackView, TextView, ViewRef,

src/bin/tui/mining.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::cmp::Ordering;
1919
use chrono::prelude::{DateTime, NaiveDateTime, Utc};
2020
use cursive::direction::Orientation;
2121
use cursive::event::Key;
22-
use cursive::traits::{Boxable, Identifiable};
22+
use cursive::traits::{Nameable, Resizable};
2323
use cursive::view::View;
2424
use cursive::views::{
2525
Button, Dialog, LinearLayout, OnEventView, Panel, ResizedView, StackView, TextView,
@@ -72,7 +72,7 @@ impl TableViewItem<StratumWorkerColumn> for WorkerStats {
7272
0,
7373
)
7474
.unwrap_or_default();
75-
let datetime: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
75+
let datetime: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive_datetime, Utc);
7676

7777
match column {
7878
StratumWorkerColumn::Id => self.id.clone(),
@@ -129,7 +129,7 @@ impl TableViewItem<DiffColumn> for DiffBlock {
129129
fn to_column(&self, column: DiffColumn) -> String {
130130
let naive_datetime =
131131
NaiveDateTime::from_timestamp_opt(self.time as i64, 0).unwrap_or_default();
132-
let datetime: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
132+
let datetime: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive_datetime, Utc);
133133

134134
match column {
135135
DiffColumn::Height => self.block_height.to_string(),

src/bin/tui/peers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use humansize::{file_size_opts::CONVENTIONAL, FileSize};
2323

2424
use cursive::direction::Orientation;
2525
use cursive::event::Key;
26-
use cursive::traits::{Boxable, Identifiable};
26+
use cursive::traits::{Nameable, Resizable};
2727
use cursive::view::View;
2828
use cursive::views::{Dialog, LinearLayout, OnEventView, ResizedView, TextView};
2929
use cursive::Cursive;

src/bin/tui/status.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
use chrono::prelude::Utc;
1818
use cursive::direction::Orientation;
19-
use cursive::traits::Identifiable;
19+
use cursive::traits::Nameable;
2020
use cursive::view::View;
2121
use cursive::views::{LinearLayout, ResizedView, TextView};
2222
use cursive::Cursive;
@@ -71,8 +71,11 @@ impl TUIStatusView {
7171
SyncStatus::TxHashsetDownload(stat) => {
7272
if stat.total_size > 0 {
7373
let percent = stat.downloaded_size * 100 / stat.total_size;
74-
let start = stat.prev_update_time.timestamp_nanos();
75-
let fin = Utc::now().timestamp_nanos();
74+
let start = stat
75+
.prev_update_time
76+
.timestamp_nanos_opt()
77+
.unwrap_or_default();
78+
let fin = Utc::now().timestamp_nanos_opt().unwrap_or_default();
7679
let dur_ms = (fin - start) as f64 * NANO_TO_MILLIS;
7780

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

src/bin/tui/ui.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ use cursive::theme::PaletteColor::{
2323
Background, Highlight, HighlightInactive, Primary, Shadow, View,
2424
};
2525
use cursive::theme::{BaseColor, BorderStyle, Color, Theme};
26-
use cursive::traits::Boxable;
27-
use cursive::traits::Identifiable;
26+
use cursive::traits::{Nameable, Resizable};
2827
use cursive::utils::markup::StyledString;
2928
use cursive::views::{
3029
CircularFocus, Dialog, LinearLayout, Panel, SelectView, StackView, TextView, ViewRef,
@@ -124,9 +123,7 @@ impl UI {
124123
let controller_tx_clone = grin_ui.controller_tx.clone();
125124
grin_ui.cursive.add_global_callback('q', move |c| {
126125
let content = StyledString::styled("Shutting down...", Color::Light(BaseColor::Yellow));
127-
c.add_layer(CircularFocus::wrap_tab(Dialog::around(TextView::new(
128-
content,
129-
))));
126+
c.add_layer(CircularFocus::new(Dialog::around(TextView::new(content))).wrap_tab());
130127
controller_tx_clone
131128
.send(ControllerMessage::Shutdown)
132129
.unwrap();

src/bin/tui/version.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! Version and build info
1616
1717
use cursive::direction::Orientation;
18-
use cursive::traits::Identifiable;
18+
use cursive::traits::Nameable;
1919
use cursive::view::View;
2020
use cursive::views::{LinearLayout, ResizedView, TextView};
2121

0 commit comments

Comments
 (0)