Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency upgrade: Cursive + Chrono warnings #3778

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
781 changes: 446 additions & 335 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ blake2-rfc = "0.2"
chrono = "0.4.11"
clap = { version = "2.33", features = ["yaml"] }
ctrlc = { version = "3.1", features = ["termination"] }
cursive_table_view = "0.13.2"
cursive_table_view = "0.14.0"
humansize = "1.1.0"
serde = "1"
futures = "0.3.19"
Expand All @@ -42,7 +42,7 @@ grin_servers = { path = "./servers", version = "5.3.0-alpha.1" }
grin_util = { path = "./util", version = "5.3.0-alpha.1" }

[dependencies.cursive]
version = "0.16"
version = "0.20"
default-features = false
features = ["pancurses-backend"]

Expand Down
6 changes: 3 additions & 3 deletions core/src/core/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,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 @@ -313,7 +313,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 @@ -667,7 +667,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 @@ -115,8 +115,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
2 changes: 1 addition & 1 deletion src/bin/tui/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use cursive::theme::{BaseColor, Color, ColorStyle};
use cursive::traits::Identifiable;
use cursive::traits::Nameable;
use cursive::view::View;
use cursive::views::ResizedView;
use cursive::{Cursive, Printer};
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use cursive::align::HAlign;
use cursive::direction::Orientation;
use cursive::event::Key;
use cursive::view::Identifiable;
use cursive::view::Nameable;
use cursive::view::View;
use cursive::views::{
LinearLayout, OnEventView, ResizedView, SelectView, StackView, TextView, ViewRef,
Expand Down
6 changes: 3 additions & 3 deletions src/bin/tui/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::cmp::Ordering;
use chrono::prelude::{DateTime, NaiveDateTime, Utc};
use cursive::direction::Orientation;
use cursive::event::Key;
use cursive::traits::{Boxable, Identifiable};
use cursive::traits::{Nameable, Resizable};
use cursive::view::View;
use cursive::views::{
Button, Dialog, LinearLayout, OnEventView, Panel, ResizedView, StackView, TextView,
Expand Down Expand Up @@ -72,7 +72,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 @@ -129,7 +129,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
2 changes: 1 addition & 1 deletion src/bin/tui/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use humansize::{file_size_opts::CONVENTIONAL, FileSize};

use cursive::direction::Orientation;
use cursive::event::Key;
use cursive::traits::{Boxable, Identifiable};
use cursive::traits::{Nameable, Resizable};
use cursive::view::View;
use cursive::views::{Dialog, LinearLayout, OnEventView, ResizedView, TextView};
use cursive::Cursive;
Expand Down
9 changes: 6 additions & 3 deletions src/bin/tui/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use chrono::prelude::Utc;
use cursive::direction::Orientation;
use cursive::traits::Identifiable;
use cursive::traits::Nameable;
use cursive::view::View;
use cursive::views::{LinearLayout, ResizedView, TextView};
use cursive::Cursive;
Expand Down 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
7 changes: 2 additions & 5 deletions src/bin/tui/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use cursive::theme::PaletteColor::{
Background, Highlight, HighlightInactive, Primary, Shadow, View,
};
use cursive::theme::{BaseColor, BorderStyle, Color, Theme};
use cursive::traits::Boxable;
use cursive::traits::Identifiable;
use cursive::traits::{Nameable, Resizable};
use cursive::utils::markup::StyledString;
use cursive::views::{
CircularFocus, Dialog, LinearLayout, Panel, SelectView, StackView, TextView, ViewRef,
Expand Down Expand Up @@ -124,9 +123,7 @@ impl UI {
let controller_tx_clone = grin_ui.controller_tx.clone();
grin_ui.cursive.add_global_callback('q', move |c| {
let content = StyledString::styled("Shutting down...", Color::Light(BaseColor::Yellow));
c.add_layer(CircularFocus::wrap_tab(Dialog::around(TextView::new(
content,
))));
c.add_layer(CircularFocus::new(Dialog::around(TextView::new(content))).wrap_tab());
controller_tx_clone
.send(ControllerMessage::Shutdown)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tui/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! Version and build info

use cursive::direction::Orientation;
use cursive::traits::Identifiable;
use cursive::traits::Nameable;
use cursive::view::View;
use cursive::views::{LinearLayout, ResizedView, TextView};

Expand Down
Loading