more chrono warnings, update cursive lib (#3778)

This commit is contained in:
Yeastplume 2024-01-29 12:50:45 +00:00 committed by GitHub
parent d1b7ae5352
commit c5efaa4e7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 472 additions and 359 deletions

783
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -24,7 +24,7 @@ blake2-rfc = "0.2"
chrono = "0.4.11" chrono = "0.4.11"
clap = { version = "2.33", features = ["yaml"] } clap = { version = "2.33", features = ["yaml"] }
ctrlc = { version = "3.1", features = ["termination"] } ctrlc = { version = "3.1", features = ["termination"] }
cursive_table_view = "0.13.2" cursive_table_view = "0.14.0"
humansize = "1.1.0" humansize = "1.1.0"
serde = "1" serde = "1"
futures = "0.3.19" futures = "0.3.19"
@ -42,7 +42,7 @@ grin_servers = { path = "./servers", version = "5.3.0-alpha.1" }
grin_util = { path = "./util", version = "5.3.0-alpha.1" } grin_util = { path = "./util", version = "5.3.0-alpha.1" }
[dependencies.cursive] [dependencies.cursive]
version = "0.16" version = "0.20"
default-features = false default-features = false
features = ["pancurses-backend"] features = ["pancurses-backend"]

View file

@ -231,7 +231,7 @@ impl Default for BlockHeader {
BlockHeader { BlockHeader {
version: HeaderVersion(1), version: HeaderVersion(1),
height: 0, height: 0,
timestamp: DateTime::<Utc>::from_utc( timestamp: DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(), NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
Utc, Utc,
), ),
@ -313,7 +313,7 @@ fn read_block_header<R: Reader>(reader: &mut R) -> Result<BlockHeader, ser::Erro
Ok(BlockHeader { Ok(BlockHeader {
version, version,
height, height,
timestamp: DateTime::<Utc>::from_utc(ts.unwrap(), Utc), timestamp: DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc),
prev_hash, prev_hash,
prev_root, prev_root,
output_root, output_root,
@ -667,7 +667,7 @@ impl Block {
return Err(Error::Other("Converting Utc::now() into timestamp".into())); 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. // Now build the block with all the above information.
// Note: We have not validated the block here. // Note: We have not validated the block here.
// Caller must validate the block as necessary. // Caller must validate the block as necessary.

View file

@ -115,8 +115,10 @@ pub fn pow_size(
// and if we're back where we started, update the time (changes the hash as // and if we're back where we started, update the time (changes the hash as
// well) // well)
if bh.pow.nonce == start_nonce { if bh.pow.nonce == start_nonce {
bh.timestamp = bh.timestamp = DateTime::from_naive_utc_and_offset(
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp_opt(0, 0).unwrap(), Utc); NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
Utc,
);
} }
} }
} }

View file

@ -172,7 +172,7 @@ fn build_block(
if ts.is_none() { if ts.is_none() {
return Err(Error::General("Utc::now into timestamp".into())); 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!( debug!(
"Built new block with {} inputs and {} outputs, block difficulty: {}, cumulative difficulty {}", "Built new block with {} inputs and {} outputs, block difficulty: {}, cumulative difficulty {}",

View file

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
use cursive::theme::{BaseColor, Color, ColorStyle}; use cursive::theme::{BaseColor, Color, ColorStyle};
use cursive::traits::Identifiable; use cursive::traits::Nameable;
use cursive::view::View; use cursive::view::View;
use cursive::views::ResizedView; use cursive::views::ResizedView;
use cursive::{Cursive, Printer}; use cursive::{Cursive, Printer};

View file

@ -17,7 +17,7 @@
use cursive::align::HAlign; use cursive::align::HAlign;
use cursive::direction::Orientation; use cursive::direction::Orientation;
use cursive::event::Key; use cursive::event::Key;
use cursive::view::Identifiable; use cursive::view::Nameable;
use cursive::view::View; use cursive::view::View;
use cursive::views::{ use cursive::views::{
LinearLayout, OnEventView, ResizedView, SelectView, StackView, TextView, ViewRef, LinearLayout, OnEventView, ResizedView, SelectView, StackView, TextView, ViewRef,

View file

@ -19,7 +19,7 @@ use std::cmp::Ordering;
use chrono::prelude::{DateTime, NaiveDateTime, Utc}; use chrono::prelude::{DateTime, NaiveDateTime, Utc};
use cursive::direction::Orientation; use cursive::direction::Orientation;
use cursive::event::Key; use cursive::event::Key;
use cursive::traits::{Boxable, Identifiable}; use cursive::traits::{Nameable, Resizable};
use cursive::view::View; use cursive::view::View;
use cursive::views::{ use cursive::views::{
Button, Dialog, LinearLayout, OnEventView, Panel, ResizedView, StackView, TextView, Button, Dialog, LinearLayout, OnEventView, Panel, ResizedView, StackView, TextView,
@ -72,7 +72,7 @@ impl TableViewItem<StratumWorkerColumn> for WorkerStats {
0, 0,
) )
.unwrap_or_default(); .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 { match column {
StratumWorkerColumn::Id => self.id.clone(), StratumWorkerColumn::Id => self.id.clone(),
@ -129,7 +129,7 @@ impl TableViewItem<DiffColumn> for DiffBlock {
fn to_column(&self, column: DiffColumn) -> String { fn to_column(&self, column: DiffColumn) -> String {
let naive_datetime = let naive_datetime =
NaiveDateTime::from_timestamp_opt(self.time as i64, 0).unwrap_or_default(); 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 { match column {
DiffColumn::Height => self.block_height.to_string(), DiffColumn::Height => self.block_height.to_string(),

View file

@ -23,7 +23,7 @@ use humansize::{file_size_opts::CONVENTIONAL, FileSize};
use cursive::direction::Orientation; use cursive::direction::Orientation;
use cursive::event::Key; use cursive::event::Key;
use cursive::traits::{Boxable, Identifiable}; use cursive::traits::{Nameable, Resizable};
use cursive::view::View; use cursive::view::View;
use cursive::views::{Dialog, LinearLayout, OnEventView, ResizedView, TextView}; use cursive::views::{Dialog, LinearLayout, OnEventView, ResizedView, TextView};
use cursive::Cursive; use cursive::Cursive;

View file

@ -16,7 +16,7 @@
use chrono::prelude::Utc; use chrono::prelude::Utc;
use cursive::direction::Orientation; use cursive::direction::Orientation;
use cursive::traits::Identifiable; use cursive::traits::Nameable;
use cursive::view::View; use cursive::view::View;
use cursive::views::{LinearLayout, ResizedView, TextView}; use cursive::views::{LinearLayout, ResizedView, TextView};
use cursive::Cursive; use cursive::Cursive;
@ -71,8 +71,11 @@ impl TUIStatusView {
SyncStatus::TxHashsetDownload(stat) => { SyncStatus::TxHashsetDownload(stat) => {
if stat.total_size > 0 { if stat.total_size > 0 {
let percent = stat.downloaded_size * 100 / stat.total_size; let percent = stat.downloaded_size * 100 / stat.total_size;
let start = stat.prev_update_time.timestamp_nanos(); let start = stat
let fin = Utc::now().timestamp_nanos(); .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; 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)", Cow::Owned(format!("Sync step 2/7: Downloading {}(MB) chain state for state sync: {}% at {:.1?}(kB/s)",

View file

@ -23,8 +23,7 @@ use cursive::theme::PaletteColor::{
Background, Highlight, HighlightInactive, Primary, Shadow, View, Background, Highlight, HighlightInactive, Primary, Shadow, View,
}; };
use cursive::theme::{BaseColor, BorderStyle, Color, Theme}; use cursive::theme::{BaseColor, BorderStyle, Color, Theme};
use cursive::traits::Boxable; use cursive::traits::{Nameable, Resizable};
use cursive::traits::Identifiable;
use cursive::utils::markup::StyledString; use cursive::utils::markup::StyledString;
use cursive::views::{ use cursive::views::{
CircularFocus, Dialog, LinearLayout, Panel, SelectView, StackView, TextView, ViewRef, CircularFocus, Dialog, LinearLayout, Panel, SelectView, StackView, TextView, ViewRef,
@ -124,9 +123,7 @@ impl UI {
let controller_tx_clone = grin_ui.controller_tx.clone(); let controller_tx_clone = grin_ui.controller_tx.clone();
grin_ui.cursive.add_global_callback('q', move |c| { grin_ui.cursive.add_global_callback('q', move |c| {
let content = StyledString::styled("Shutting down...", Color::Light(BaseColor::Yellow)); let content = StyledString::styled("Shutting down...", Color::Light(BaseColor::Yellow));
c.add_layer(CircularFocus::wrap_tab(Dialog::around(TextView::new( c.add_layer(CircularFocus::new(Dialog::around(TextView::new(content))).wrap_tab());
content,
))));
controller_tx_clone controller_tx_clone
.send(ControllerMessage::Shutdown) .send(ControllerMessage::Shutdown)
.unwrap(); .unwrap();

View file

@ -15,7 +15,7 @@
//! Version and build info //! Version and build info
use cursive::direction::Orientation; use cursive::direction::Orientation;
use cursive::traits::Identifiable; use cursive::traits::Nameable;
use cursive::view::View; use cursive::view::View;
use cursive::views::{LinearLayout, ResizedView, TextView}; use cursive::views::{LinearLayout, ResizedView, TextView};