Rust 1.80+ fixes & accumulated warning cleanup (#3796)
* Update versioning on master to 5.4.0-alpha.0 * updates for 1.80 and other accumulated warnings * further warning cleanups * move dead code tag to function defn rather than module
This commit is contained in:
@@ -27,7 +27,7 @@ use crate::pow::{verify_size, Difficulty, Proof, ProofOfWork};
|
||||
use crate::ser::{
|
||||
self, deserialize_default, serialize_default, PMMRable, Readable, Reader, Writeable, Writer,
|
||||
};
|
||||
use chrono::prelude::{DateTime, NaiveDateTime, Utc};
|
||||
use chrono::prelude::{DateTime, Utc};
|
||||
use chrono::Duration;
|
||||
use keychain::{self, BlindingFactor};
|
||||
use std::convert::TryInto;
|
||||
@@ -232,7 +232,7 @@ impl Default for BlockHeader {
|
||||
version: HeaderVersion(1),
|
||||
height: 0,
|
||||
timestamp: DateTime::from_naive_utc_and_offset(
|
||||
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
|
||||
DateTime::<Utc>::from_timestamp(0, 0).unwrap().naive_utc(),
|
||||
Utc,
|
||||
),
|
||||
prev_hash: ZERO_HASH,
|
||||
@@ -295,17 +295,19 @@ fn read_block_header<R: Reader>(reader: &mut R) -> Result<BlockHeader, ser::Erro
|
||||
> chrono::NaiveDate::MAX
|
||||
.and_hms_opt(0, 0, 0)
|
||||
.unwrap()
|
||||
.and_utc()
|
||||
.timestamp()
|
||||
|| timestamp
|
||||
< chrono::NaiveDate::MIN
|
||||
.and_hms_opt(0, 0, 0)
|
||||
.unwrap()
|
||||
.and_utc()
|
||||
.timestamp()
|
||||
{
|
||||
return Err(ser::Error::CorruptedData);
|
||||
}
|
||||
|
||||
let ts = NaiveDateTime::from_timestamp_opt(timestamp, 0);
|
||||
let ts = DateTime::<Utc>::from_timestamp(timestamp, 0);
|
||||
if ts.is_none() {
|
||||
return Err(ser::Error::CorruptedData);
|
||||
}
|
||||
@@ -313,7 +315,7 @@ fn read_block_header<R: Reader>(reader: &mut R) -> Result<BlockHeader, ser::Erro
|
||||
Ok(BlockHeader {
|
||||
version,
|
||||
height,
|
||||
timestamp: DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc),
|
||||
timestamp: DateTime::from_naive_utc_and_offset(ts.unwrap().naive_utc(), Utc),
|
||||
prev_hash,
|
||||
prev_root,
|
||||
output_root,
|
||||
@@ -662,12 +664,12 @@ impl Block {
|
||||
|
||||
let now = Utc::now().timestamp();
|
||||
|
||||
let ts = NaiveDateTime::from_timestamp_opt(now, 0);
|
||||
let ts = DateTime::<Utc>::from_timestamp(now, 0);
|
||||
if ts.is_none() {
|
||||
return Err(Error::Other("Converting Utc::now() into timestamp".into()));
|
||||
}
|
||||
|
||||
let timestamp = DateTime::from_naive_utc_and_offset(ts.unwrap(), Utc);
|
||||
let timestamp = DateTime::from_naive_utc_and_offset(ts.unwrap().naive_utc(), 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.
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
// required for genesis replacement
|
||||
//! #![allow(unused_imports)]
|
||||
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]
|
||||
|
||||
use crate::core;
|
||||
use crate::core::hash::Hash;
|
||||
use crate::pow::{Difficulty, Proof, ProofOfWork};
|
||||
@@ -44,7 +42,6 @@ pub fn genesis_dev() -> core::Block {
|
||||
}
|
||||
|
||||
/// Testnet genesis block
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
pub fn genesis_test() -> core::Block {
|
||||
let gen = core::Block::with_header(core::BlockHeader {
|
||||
height: 0,
|
||||
@@ -157,7 +154,6 @@ pub fn genesis_test() -> core::Block {
|
||||
}
|
||||
|
||||
/// Mainnet genesis block
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
pub fn genesis_main() -> core::Block {
|
||||
let gen = core::Block::with_header(core::BlockHeader {
|
||||
height: 0,
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ pub use crate::pow::cuckaroom::{new_cuckaroom_ctx, CuckaroomContext};
|
||||
pub use crate::pow::cuckarooz::{new_cuckarooz_ctx, CuckaroozContext};
|
||||
pub use crate::pow::cuckatoo::{new_cuckatoo_ctx, CuckatooContext};
|
||||
pub use crate::pow::error::Error;
|
||||
use chrono::prelude::{DateTime, NaiveDateTime, Utc};
|
||||
use chrono::prelude::{DateTime, Utc};
|
||||
|
||||
const MAX_SOLS: u32 = 10;
|
||||
|
||||
@@ -116,7 +116,7 @@ pub fn pow_size(
|
||||
// well)
|
||||
if bh.pow.nonce == start_nonce {
|
||||
bh.timestamp = DateTime::from_naive_utc_and_offset(
|
||||
NaiveDateTime::from_timestamp_opt(0, 0).unwrap(),
|
||||
DateTime::<Utc>::from_timestamp(0, 0).unwrap().naive_utc(),
|
||||
Utc,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ pub fn create_siphash_keys(header: &[u8]) -> Result<[u64; 4], Error> {
|
||||
/// Utility struct to calculate commonly used Cuckoo parameters calculated
|
||||
/// from header, nonce, edge_bits, etc.
|
||||
pub struct CuckooParams {
|
||||
pub edge_bits: u8,
|
||||
pub proof_size: usize,
|
||||
pub num_edges: u64,
|
||||
pub siphash_keys: [u64; 4],
|
||||
@@ -98,7 +97,6 @@ impl CuckooParams {
|
||||
let num_nodes = 1u64 << node_bits;
|
||||
let node_mask = num_nodes - 1;
|
||||
Ok(CuckooParams {
|
||||
edge_bits,
|
||||
proof_size,
|
||||
num_edges,
|
||||
siphash_keys: [0; 4],
|
||||
|
||||
Reference in New Issue
Block a user