mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
more chrono warnings, update cursive lib (#3778)
This commit is contained in:
parent
d1b7ae5352
commit
c5efaa4e7c
12 changed files with 472 additions and 359 deletions
783
Cargo.lock
generated
783
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -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"
|
||||
|
@ -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"]
|
||||
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {}",
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -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(),
|
||||
|
@ -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(),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -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)",
|
||||
|
|
|
@ -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,
|
||||
|
@ -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();
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
Loading…
Reference in a new issue