Addresses clippy lints (#8723)
This commit is contained in:
parent
0fdd26431e
commit
6181ebe239
|
@ -27,6 +27,7 @@ impl Arbitrary for DateTime32 {
|
||||||
/// - making durations and intervals 3 seconds or longer,
|
/// - making durations and intervals 3 seconds or longer,
|
||||||
/// - avoiding complex time-based calculations, and
|
/// - avoiding complex time-based calculations, and
|
||||||
/// - avoiding relying on subsecond precision or time order.
|
/// - avoiding relying on subsecond precision or time order.
|
||||||
|
///
|
||||||
/// When monotonic times are needed, use the opaque `std::time::Instant` type.
|
/// When monotonic times are needed, use the opaque `std::time::Instant` type.
|
||||||
///
|
///
|
||||||
/// # Usage
|
/// # Usage
|
||||||
|
|
|
@ -97,6 +97,7 @@ pub fn difficulty_threshold_is_valid(
|
||||||
/// Returns `Ok(())` if `hash` passes:
|
/// Returns `Ok(())` if `hash` passes:
|
||||||
/// - the target difficulty limit for `network` (PoWLimit), and
|
/// - the target difficulty limit for `network` (PoWLimit), and
|
||||||
/// - the difficulty filter,
|
/// - the difficulty filter,
|
||||||
|
///
|
||||||
/// based on the fields in `header`.
|
/// based on the fields in `header`.
|
||||||
///
|
///
|
||||||
/// If the block is invalid, returns an error containing `height` and `hash`.
|
/// If the block is invalid, returns an error containing `height` and `hash`.
|
||||||
|
|
|
@ -49,9 +49,11 @@ use crate::error::TransactionError;
|
||||||
///
|
///
|
||||||
/// > the nTime field MUST represent a time strictly greater than the median of the
|
/// > the nTime field MUST represent a time strictly greater than the median of the
|
||||||
/// > timestamps of the past PoWMedianBlockSpan blocks.
|
/// > timestamps of the past PoWMedianBlockSpan blocks.
|
||||||
|
///
|
||||||
/// <https://zips.z.cash/protocol/protocol.pdf#blockheader>
|
/// <https://zips.z.cash/protocol/protocol.pdf#blockheader>
|
||||||
///
|
///
|
||||||
/// > The transaction can be added to any block whose block time is greater than the locktime.
|
/// > The transaction can be added to any block whose block time is greater than the locktime.
|
||||||
|
///
|
||||||
/// <https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number>
|
/// <https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number>
|
||||||
///
|
///
|
||||||
/// If the transaction's lock time is less than the median-time-past,
|
/// If the transaction's lock time is less than the median-time-past,
|
||||||
|
|
|
@ -9,10 +9,9 @@ use crate::methods::get_block_template_rpcs::GetBlockTemplateRpc;
|
||||||
/// See notes for [`GetBlockTemplateRpc::submit_block`] method
|
/// See notes for [`GetBlockTemplateRpc::submit_block`] method
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
|
||||||
pub struct JsonParameters {
|
pub struct JsonParameters {
|
||||||
/// The workid for the block template.
|
/// The workid for the block template. Currently unused.
|
||||||
///
|
///
|
||||||
/// > If the server provided a workid, it MUST be included with submissions,
|
/// > If the server provided a workid, it MUST be included with submissions,
|
||||||
/// currently unused.
|
|
||||||
///
|
///
|
||||||
/// Rationale:
|
/// Rationale:
|
||||||
///
|
///
|
||||||
|
|
|
@ -29,6 +29,7 @@ use crate::{
|
||||||
/// - Returns an error, or
|
/// - Returns an error, or
|
||||||
/// - Returns the block hash of a block that the read state already contains,
|
/// - Returns the block hash of a block that the read state already contains,
|
||||||
/// (so that there's nothing for the syncer to do except wait for the next chain tip change).
|
/// (so that there's nothing for the syncer to do except wait for the next chain tip change).
|
||||||
|
///
|
||||||
/// See the [`TrustedChainSync::wait_for_chain_tip_change()`] method documentation for more information.
|
/// See the [`TrustedChainSync::wait_for_chain_tip_change()`] method documentation for more information.
|
||||||
const POLL_DELAY: Duration = Duration::from_millis(200);
|
const POLL_DELAY: Duration = Duration::from_millis(200);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub fn main() {
|
||||||
|
|
||||||
for txid in txids.iter() {
|
for txid in txids.iter() {
|
||||||
let tx = Transaction::read(
|
let tx = Transaction::read(
|
||||||
&hex::decode(&fetch_tx_via_rpc(txid.encode_hex()))
|
&hex::decode(fetch_tx_via_rpc(txid.encode_hex()))
|
||||||
.expect("RPC response should be decodable from hex string to bytes")[..],
|
.expect("RPC response should be decodable from hex string to bytes")[..],
|
||||||
BranchId::for_height(&network, height),
|
BranchId::for_height(&network, height),
|
||||||
)
|
)
|
||||||
|
|
|
@ -389,6 +389,7 @@ impl DiskWriteBatch {
|
||||||
/// - insert created UTXOs,
|
/// - insert created UTXOs,
|
||||||
/// - insert transparent address UTXO index entries, and
|
/// - insert transparent address UTXO index entries, and
|
||||||
/// - insert transparent address transaction entries,
|
/// - insert transparent address transaction entries,
|
||||||
|
///
|
||||||
/// without actually writing anything.
|
/// without actually writing anything.
|
||||||
///
|
///
|
||||||
/// Also modifies the `address_balances` for these new UTXOs.
|
/// Also modifies the `address_balances` for these new UTXOs.
|
||||||
|
@ -466,6 +467,7 @@ impl DiskWriteBatch {
|
||||||
/// Adds the following changes to this batch:
|
/// Adds the following changes to this batch:
|
||||||
/// - delete spent UTXOs, and
|
/// - delete spent UTXOs, and
|
||||||
/// - delete transparent address UTXO index entries,
|
/// - delete transparent address UTXO index entries,
|
||||||
|
///
|
||||||
/// without actually writing anything.
|
/// without actually writing anything.
|
||||||
///
|
///
|
||||||
/// Also modifies the `address_balances` for these new UTXOs.
|
/// Also modifies the `address_balances` for these new UTXOs.
|
||||||
|
@ -523,6 +525,7 @@ impl DiskWriteBatch {
|
||||||
/// Adds the following changes to this batch:
|
/// Adds the following changes to this batch:
|
||||||
/// - index spending transactions for each spent transparent output
|
/// - index spending transactions for each spent transparent output
|
||||||
/// (this is different from the transaction that created the output),
|
/// (this is different from the transaction that created the output),
|
||||||
|
///
|
||||||
/// without actually writing anything.
|
/// without actually writing anything.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
@ -573,6 +576,7 @@ impl DiskWriteBatch {
|
||||||
|
|
||||||
/// Prepare a database batch containing `finalized.block`'s:
|
/// Prepare a database batch containing `finalized.block`'s:
|
||||||
/// - transparent address balance changes,
|
/// - transparent address balance changes,
|
||||||
|
///
|
||||||
/// and return it (without actually writing anything).
|
/// and return it (without actually writing anything).
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
|
|
@ -182,6 +182,7 @@ impl NonFinalizedState {
|
||||||
// Chain::cmp uses the partial cumulative work, and the hash of the tip block.
|
// Chain::cmp uses the partial cumulative work, and the hash of the tip block.
|
||||||
// Neither of these fields has interior mutability.
|
// Neither of these fields has interior mutability.
|
||||||
// (And when the tip block is dropped for a chain, the chain is also dropped.)
|
// (And when the tip block is dropped for a chain, the chain is also dropped.)
|
||||||
|
#[allow(clippy::mutable_key_type)]
|
||||||
let chains = mem::take(&mut self.chain_set);
|
let chains = mem::take(&mut self.chain_set);
|
||||||
let mut chains = chains.into_iter();
|
let mut chains = chains.into_iter();
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ pub const PEER_GOSSIP_DELAY: Duration = Duration::from_secs(7);
|
||||||
/// This timeout makes sure that the syncer doesn't hang when:
|
/// This timeout makes sure that the syncer doesn't hang when:
|
||||||
/// - the lookahead queue is full, and
|
/// - the lookahead queue is full, and
|
||||||
/// - we are waiting for a request that is stuck.
|
/// - we are waiting for a request that is stuck.
|
||||||
|
///
|
||||||
/// See [`BLOCK_VERIFY_TIMEOUT`] for details.
|
/// See [`BLOCK_VERIFY_TIMEOUT`] for details.
|
||||||
///
|
///
|
||||||
/// ## Correctness
|
/// ## Correctness
|
||||||
|
@ -149,6 +150,7 @@ pub(super) const BLOCK_DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(20);
|
||||||
/// - are for blocks a long way ahead of the current tip, or
|
/// - are for blocks a long way ahead of the current tip, or
|
||||||
/// - are for invalid blocks which will never verify, because they depend on
|
/// - are for invalid blocks which will never verify, because they depend on
|
||||||
/// missing blocks or transactions.
|
/// missing blocks or transactions.
|
||||||
|
///
|
||||||
/// These conditions can happen during normal operation - they are not bugs.
|
/// These conditions can happen during normal operation - they are not bugs.
|
||||||
///
|
///
|
||||||
/// This timeout also mitigates or hides the following kinds of bugs:
|
/// This timeout also mitigates or hides the following kinds of bugs:
|
||||||
|
|
|
@ -811,28 +811,13 @@ fn last_config_is_stored() -> Result<()> {
|
||||||
\n\
|
\n\
|
||||||
Take the missing config file logged above, \n\
|
Take the missing config file logged above, \n\
|
||||||
and commit it to Zebra's git repository as:\n\
|
and commit it to Zebra's git repository as:\n\
|
||||||
zebrad/tests/common/configs/{}<next-release-tag>.toml \n\
|
zebrad/tests/common/configs/<next-release-tag>.toml \n\
|
||||||
\n\
|
\n\
|
||||||
Or run: \n\
|
Or run: \n\
|
||||||
cargo build {}--bin zebrad && \n\
|
cargo build --bin zebrad && \n\
|
||||||
zebrad generate | \n\
|
zebrad generate | \n\
|
||||||
sed 's/cache_dir = \".*\"/cache_dir = \"cache_dir\"/' > \n\
|
sed 's/cache_dir = \".*\"/cache_dir = \"cache_dir\"/' > \n\
|
||||||
zebrad/tests/common/configs/{}<next-release-tag>.toml",
|
zebrad/tests/common/configs/<next-release-tag>.toml",
|
||||||
if cfg!(feature = "shielded-scan") {
|
|
||||||
SHIELDED_SCAN_CONFIG_PREFIX
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
},
|
|
||||||
if cfg!(feature = "shielded-scan") {
|
|
||||||
"--features=shielded-scan "
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
},
|
|
||||||
if cfg!(feature = "shielded-scan") {
|
|
||||||
SHIELDED_SCAN_CONFIG_PREFIX
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
},
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,7 +948,6 @@ fn stored_configs_parsed_correctly() -> Result<()> {
|
||||||
|
|
||||||
// ignore files starting with shieldedscan prefix
|
// ignore files starting with shieldedscan prefix
|
||||||
// if we were not built with the shielded-scan feature.
|
// if we were not built with the shielded-scan feature.
|
||||||
#[cfg(not(feature = "shielded-scan"))]
|
|
||||||
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
||||||
tracing::info!(?config_file_path, "skipping shielded-scan config file path");
|
tracing::info!(?config_file_path, "skipping shielded-scan config file path");
|
||||||
continue;
|
continue;
|
||||||
|
@ -1021,14 +1005,6 @@ fn stored_configs_work() -> Result<()> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore files starting with shieldedscan prefix
|
|
||||||
// if we were not built with the shielded-scan feature.
|
|
||||||
#[cfg(not(feature = "shielded-scan"))]
|
|
||||||
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
|
||||||
tracing::info!(?config_file_path, "skipping shielded-scan config file path");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let run_dir = testdir()?;
|
let run_dir = testdir()?;
|
||||||
let stored_config_path = config_file_full_path(config_file.path());
|
let stored_config_path = config_file_full_path(config_file.path());
|
||||||
|
|
||||||
|
|
|
@ -80,27 +80,6 @@ pub fn default_test_config(net: &Network) -> Result<ZebradConfig> {
|
||||||
mining.miner_address = Some(miner_address.parse().expect("hard-coded address is valid"));
|
mining.miner_address = Some(miner_address.parse().expect("hard-coded address is valid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "shielded-scan")]
|
|
||||||
{
|
|
||||||
let mut shielded_scan = zebra_scan::Config::ephemeral();
|
|
||||||
shielded_scan.db_config_mut().cache_dir = "zebra-scan".into();
|
|
||||||
|
|
||||||
let config = ZebradConfig {
|
|
||||||
network,
|
|
||||||
state,
|
|
||||||
sync,
|
|
||||||
mempool,
|
|
||||||
consensus,
|
|
||||||
tracing,
|
|
||||||
mining,
|
|
||||||
shielded_scan,
|
|
||||||
..ZebradConfig::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "shielded-scan"))]
|
|
||||||
Ok(ZebradConfig {
|
Ok(ZebradConfig {
|
||||||
network,
|
network,
|
||||||
state,
|
state,
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
# Default configuration for zebrad.
|
|
||||||
#
|
|
||||||
# This file can be used as a skeleton for custom configs.
|
|
||||||
#
|
|
||||||
# Unspecified fields use default values. Optional fields are Some(field) if the
|
|
||||||
# field is present and None if it is absent.
|
|
||||||
#
|
|
||||||
# This file is generated as an example using zebrad's current defaults.
|
|
||||||
# You should set only the config options you want to keep, and delete the rest.
|
|
||||||
# Only a subset of fields are present in the skeleton, since optional values
|
|
||||||
# whose default is None are omitted.
|
|
||||||
#
|
|
||||||
# The config format (including a complete list of sections and fields) is
|
|
||||||
# documented here:
|
|
||||||
# https://docs.rs/zebrad/latest/zebrad/config/struct.ZebradConfig.html
|
|
||||||
#
|
|
||||||
# zebrad attempts to load configs in the following order:
|
|
||||||
#
|
|
||||||
# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`;
|
|
||||||
# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent);
|
|
||||||
# 3. The default config.
|
|
||||||
|
|
||||||
[consensus]
|
|
||||||
checkpoint_sync = true
|
|
||||||
|
|
||||||
[mempool]
|
|
||||||
eviction_memory_time = "1h"
|
|
||||||
tx_cost_limit = 80000000
|
|
||||||
|
|
||||||
[metrics]
|
|
||||||
|
|
||||||
[mining]
|
|
||||||
debug_like_zcashd = true
|
|
||||||
|
|
||||||
[network]
|
|
||||||
cache_dir = true
|
|
||||||
crawl_new_peer_interval = "1m 1s"
|
|
||||||
initial_mainnet_peers = [
|
|
||||||
"dnsseed.z.cash:8233",
|
|
||||||
"dnsseed.str4d.xyz:8233",
|
|
||||||
"mainnet.seeder.zfnd.org:8233",
|
|
||||||
"mainnet.is.yolo.money:8233",
|
|
||||||
]
|
|
||||||
initial_testnet_peers = [
|
|
||||||
"dnsseed.testnet.z.cash:18233",
|
|
||||||
"testnet.seeder.zfnd.org:18233",
|
|
||||||
"testnet.is.yolo.money:18233",
|
|
||||||
]
|
|
||||||
listen_addr = "0.0.0.0:8233"
|
|
||||||
max_connections_per_ip = 1
|
|
||||||
network = "Mainnet"
|
|
||||||
peerset_initial_target_size = 25
|
|
||||||
|
|
||||||
[rpc]
|
|
||||||
debug_force_finished_sync = false
|
|
||||||
parallel_cpu_threads = 0
|
|
||||||
|
|
||||||
[shielded_scan]
|
|
||||||
cache_dir = "cache_dir"
|
|
||||||
delete_old_database = true
|
|
||||||
ephemeral = false
|
|
||||||
|
|
||||||
[shielded_scan.sapling_keys_to_scan]
|
|
||||||
|
|
||||||
[state]
|
|
||||||
cache_dir = "cache_dir"
|
|
||||||
delete_old_database = true
|
|
||||||
ephemeral = false
|
|
||||||
|
|
||||||
[sync]
|
|
||||||
checkpoint_verify_concurrency_limit = 1000
|
|
||||||
download_concurrency_limit = 50
|
|
||||||
full_verify_concurrency_limit = 20
|
|
||||||
parallel_cpu_threads = 0
|
|
||||||
|
|
||||||
[tracing]
|
|
||||||
buffer_limit = 128000
|
|
||||||
force_use_color = false
|
|
||||||
use_color = true
|
|
||||||
use_journald = false
|
|
|
@ -1,89 +0,0 @@
|
||||||
# Default configuration for zebrad.
|
|
||||||
#
|
|
||||||
# This file can be used as a skeleton for custom configs.
|
|
||||||
#
|
|
||||||
# Unspecified fields use default values. Optional fields are Some(field) if the
|
|
||||||
# field is present and None if it is absent.
|
|
||||||
#
|
|
||||||
# This file is generated as an example using zebrad's current defaults.
|
|
||||||
# You should set only the config options you want to keep, and delete the rest.
|
|
||||||
# Only a subset of fields are present in the skeleton, since optional values
|
|
||||||
# whose default is None are omitted.
|
|
||||||
#
|
|
||||||
# The config format (including a complete list of sections and fields) is
|
|
||||||
# documented here:
|
|
||||||
# https://docs.rs/zebrad/latest/zebrad/config/struct.ZebradConfig.html
|
|
||||||
#
|
|
||||||
# zebrad attempts to load configs in the following order:
|
|
||||||
#
|
|
||||||
# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`;
|
|
||||||
# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent);
|
|
||||||
# 3. The default config.
|
|
||||||
#
|
|
||||||
# The user's preference directory and the default path to the `zebrad` config are platform dependent,
|
|
||||||
# based on `dirs::preference_dir`, see https://docs.rs/dirs/latest/dirs/fn.preference_dir.html :
|
|
||||||
#
|
|
||||||
# | Platform | Value | Example |
|
|
||||||
# | -------- | ------------------------------------- | ---------------------------------------------- |
|
|
||||||
# | Linux | `$XDG_CONFIG_HOME` or `$HOME/.config` | `/home/alice/.config/zebrad.toml` |
|
|
||||||
# | macOS | `$HOME/Library/Preferences` | `/Users/Alice/Library/Preferences/zebrad.toml` |
|
|
||||||
# | Windows | `{FOLDERID_RoamingAppData}` | `C:\Users\Alice\AppData\Local\zebrad.toml` |
|
|
||||||
|
|
||||||
[consensus]
|
|
||||||
checkpoint_sync = true
|
|
||||||
|
|
||||||
[mempool]
|
|
||||||
eviction_memory_time = "1h"
|
|
||||||
tx_cost_limit = 80000000
|
|
||||||
|
|
||||||
[metrics]
|
|
||||||
|
|
||||||
[mining]
|
|
||||||
debug_like_zcashd = true
|
|
||||||
|
|
||||||
[network]
|
|
||||||
cache_dir = true
|
|
||||||
crawl_new_peer_interval = "1m 1s"
|
|
||||||
initial_mainnet_peers = [
|
|
||||||
"dnsseed.z.cash:8233",
|
|
||||||
"dnsseed.str4d.xyz:8233",
|
|
||||||
"mainnet.seeder.zfnd.org:8233",
|
|
||||||
"mainnet.is.yolo.money:8233",
|
|
||||||
]
|
|
||||||
initial_testnet_peers = [
|
|
||||||
"dnsseed.testnet.z.cash:18233",
|
|
||||||
"testnet.seeder.zfnd.org:18233",
|
|
||||||
"testnet.is.yolo.money:18233",
|
|
||||||
]
|
|
||||||
listen_addr = "0.0.0.0:8233"
|
|
||||||
max_connections_per_ip = 1
|
|
||||||
network = "Mainnet"
|
|
||||||
peerset_initial_target_size = 25
|
|
||||||
|
|
||||||
[rpc]
|
|
||||||
debug_force_finished_sync = false
|
|
||||||
parallel_cpu_threads = 0
|
|
||||||
|
|
||||||
[shielded_scan]
|
|
||||||
cache_dir = "cache_dir"
|
|
||||||
delete_old_database = true
|
|
||||||
ephemeral = false
|
|
||||||
|
|
||||||
[shielded_scan.sapling_keys_to_scan]
|
|
||||||
|
|
||||||
[state]
|
|
||||||
cache_dir = "cache_dir"
|
|
||||||
delete_old_database = true
|
|
||||||
ephemeral = false
|
|
||||||
|
|
||||||
[sync]
|
|
||||||
checkpoint_verify_concurrency_limit = 1000
|
|
||||||
download_concurrency_limit = 50
|
|
||||||
full_verify_concurrency_limit = 20
|
|
||||||
parallel_cpu_threads = 0
|
|
||||||
|
|
||||||
[tracing]
|
|
||||||
buffer_limit = 128000
|
|
||||||
force_use_color = false
|
|
||||||
use_color = true
|
|
||||||
use_journald = false
|
|
|
@ -31,8 +31,7 @@
|
||||||
//!
|
//!
|
||||||
//! - `GetLightdInfo`: Covered.
|
//! - `GetLightdInfo`: Covered.
|
||||||
//!
|
//!
|
||||||
//! - `Ping`: Not covered and it will never be. `Ping` is only used for testing
|
//! - `Ping`: Not covered and it will never be. `Ping` is only used for testing purposes.
|
||||||
//! purposes.
|
|
||||||
|
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
|
|
Loading…
Reference in New Issue