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

Fix all redundant-static-lifetimes clippy warnings #5625

Merged
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
8 changes: 4 additions & 4 deletions stacks-common/src/util/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ macro_rules! define_named_enum {
$($Variant),*,
}
impl $Name {
pub const ALL: &'static [$Name] = &[$($Name::$Variant),*];
pub const ALL_NAMES: &'static [&'static str] = &[$($VarName),*];
pub const ALL: &[$Name] = &[$($Name::$Variant),*];
pub const ALL_NAMES: &[&str] = &[$($VarName),*];

pub fn lookup_by_name(name: &str) -> Option<Self> {
match name {
Expand Down Expand Up @@ -113,8 +113,8 @@ macro_rules! define_versioned_named_enum_internal {
}

impl $Name {
pub const ALL: &'static [$Name] = &[$($Name::$Variant),*];
pub const ALL_NAMES: &'static [&'static str] = &[$($VarName),*];
pub const ALL: &[$Name] = &[$($Name::$Variant),*];
pub const ALL_NAMES: &[&str] = &[$($VarName),*];

pub fn lookup_by_name(name: &str) -> Option<Self> {
match name {
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/burnchains/bitcoin/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ pub const ADDRESS_VERSION_TESTNET_SINGLESIG: u8 = 111;
pub const ADDRESS_VERSION_TESTNET_MULTISIG: u8 = 196;

// segwit hrps
pub const SEGWIT_MAINNET_HRP: &'static str = "bc";
pub const SEGWIT_TESTNET_HRP: &'static str = "tb";
pub const SEGWIT_MAINNET_HRP: &str = "bc";
pub const SEGWIT_TESTNET_HRP: &str = "tb";

// segwit witnes versions
pub const SEGWIT_V0: u8 = 0;
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/burnchains/bitcoin/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ use crate::core::{
};
use crate::util_lib::db::Error as DBError;

pub const USER_AGENT: &'static str = "Stacks/2.1";
pub const USER_AGENT: &str = "Stacks/2.1";

pub const BITCOIN_MAINNET: u32 = 0xD9B4BEF9;
pub const BITCOIN_TESTNET: u32 = 0x0709110B;
pub const BITCOIN_REGTEST: u32 = 0xDAB5BFFA;

pub const BITCOIN_MAINNET_NAME: &'static str = "mainnet";
pub const BITCOIN_TESTNET_NAME: &'static str = "testnet";
pub const BITCOIN_REGTEST_NAME: &'static str = "regtest";
pub const BITCOIN_MAINNET_NAME: &str = "mainnet";
pub const BITCOIN_TESTNET_NAME: &str = "testnet";
pub const BITCOIN_REGTEST_NAME: &str = "regtest";

// batch size for searching for a reorg
// kept small since sometimes bitcoin will just send us one header at a time
Expand Down
16 changes: 8 additions & 8 deletions stackslib/src/burnchains/bitcoin/spv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ use crate::util_lib::db::{

const BLOCK_HEADER_SIZE: u64 = 81;

pub const BITCOIN_GENESIS_BLOCK_HASH_MAINNET: &'static str =
pub const BITCOIN_GENESIS_BLOCK_HASH_MAINNET: &str =
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
pub const BITCOIN_GENESIS_BLOCK_MERKLE_ROOT_MAINNET: &'static str =
pub const BITCOIN_GENESIS_BLOCK_MERKLE_ROOT_MAINNET: &str =
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";

pub const BITCOIN_GENESIS_BLOCK_HASH_TESTNET: &'static str =
pub const BITCOIN_GENESIS_BLOCK_HASH_TESTNET: &str =
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";

pub const BITCOIN_GENESIS_BLOCK_HASH_REGTEST: &'static str =
pub const BITCOIN_GENESIS_BLOCK_HASH_REGTEST: &str =
"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";

pub const BLOCK_DIFFICULTY_CHUNK_SIZE: u64 = 2016;
const BLOCK_DIFFICULTY_INTERVAL: u32 = 14 * 24 * 60 * 60; // two weeks, in seconds

pub const SPV_DB_VERSION: &'static str = "3";
pub const SPV_DB_VERSION: &str = "3";

const SPV_INITIAL_SCHEMA: &[&'static str] = &[
const SPV_INITIAL_SCHEMA: &[&str] = &[
r#"
CREATE TABLE headers(
version INTEGER NOT NULL,
Expand All @@ -81,15 +81,15 @@ const SPV_INITIAL_SCHEMA: &[&'static str] = &[
// unlike the `headers` table, this table will never be deleted from, since we use it to determine
// whether or not newly-arrived headers represent a better chain than the best-known chain. The
// only way to _replace_ a row is to find a header difficulty interval with a _higher_ work score.
const SPV_SCHEMA_2: &[&'static str] = &[r#"
const SPV_SCHEMA_2: &[&str] = &[r#"
CREATE TABLE chain_work(
interval INTEGER PRIMARY KEY,
work TEXT NOT NULL -- 32-byte (256-bit) integer
);
"#];

// force the node to go and store the burnchain block header hash as well
const SPV_SCHEMA_3: &[&'static str] = &[
const SPV_SCHEMA_3: &[&str] = &[
r#"
DROP TABLE headers;
"#,
Expand Down
9 changes: 4 additions & 5 deletions stackslib/src/burnchains/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ impl FromRow<BlockstackOperationType> for BlockstackOperationType {
}
}

pub const BURNCHAIN_DB_VERSION: &'static str = "2";
pub const BURNCHAIN_DB_VERSION: &str = "2";

const BURNCHAIN_DB_SCHEMA: &'static str = r#"
const BURNCHAIN_DB_SCHEMA: &str = r#"
CREATE TABLE burnchain_db_block_headers (
-- height of the block (non-negative)
block_height INTEGER NOT NULL,
Expand Down Expand Up @@ -299,9 +299,8 @@ CREATE TABLE db_config(version TEXT NOT NULL);
INSERT INTO affirmation_maps(affirmation_id,weight,affirmation_map) VALUES (0,0,"");
"#;

const LAST_BURNCHAIN_DB_INDEX: &'static str =
"index_block_commit_metadata_burn_block_hash_anchor_block";
const BURNCHAIN_DB_INDEXES: &'static [&'static str] = &[
const LAST_BURNCHAIN_DB_INDEX: &str = "index_block_commit_metadata_burn_block_hash_anchor_block";
const BURNCHAIN_DB_INDEXES: &[&str] = &[
"CREATE INDEX IF NOT EXISTS index_burnchain_db_block_headers_height_hash ON burnchain_db_block_headers(block_height DESC, block_hash ASC);",
"CREATE INDEX IF NOT EXISTS index_burnchain_db_block_hash ON burnchain_db_block_ops(block_hash);",
"CREATE INDEX IF NOT EXISTS index_burnchain_db_txid ON burnchain_db_block_ops(txid);",
Expand Down
24 changes: 12 additions & 12 deletions stackslib/src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ impl FromRow<StacksEpoch> for StacksEpoch {
}
}

pub const SORTITION_DB_VERSION: &'static str = "9";
pub const SORTITION_DB_VERSION: &str = "9";

const SORTITION_DB_INITIAL_SCHEMA: &'static [&'static str] = &[
const SORTITION_DB_INITIAL_SCHEMA: &[&str] = &[
r#"
PRAGMA foreign_keys = ON;
"#,
Expand Down Expand Up @@ -652,7 +652,7 @@ const SORTITION_DB_INITIAL_SCHEMA: &'static [&'static str] = &[
"CREATE TABLE db_config(version TEXT PRIMARY KEY);",
];

const SORTITION_DB_SCHEMA_2: &'static [&'static str] = &[r#"
const SORTITION_DB_SCHEMA_2: &[&str] = &[r#"
CREATE TABLE epochs (
start_block_height INTEGER NOT NULL,
end_block_height INTEGER NOT NULL,
Expand All @@ -662,7 +662,7 @@ const SORTITION_DB_SCHEMA_2: &'static [&'static str] = &[r#"
PRIMARY KEY(start_block_height,epoch_id)
);"#];

const SORTITION_DB_SCHEMA_3: &'static [&'static str] = &[r#"
const SORTITION_DB_SCHEMA_3: &[&str] = &[r#"
CREATE TABLE block_commit_parents (
block_commit_txid TEXT NOT NULL,
block_commit_sortition_id TEXT NOT NULL,
Expand All @@ -673,7 +673,7 @@ const SORTITION_DB_SCHEMA_3: &'static [&'static str] = &[r#"
FOREIGN KEY(block_commit_txid,block_commit_sortition_id) REFERENCES block_commits(txid,sortition_id)
);"#];

const SORTITION_DB_SCHEMA_4: &'static [&'static str] = &[
const SORTITION_DB_SCHEMA_4: &[&str] = &[
r#"
CREATE TABLE delegate_stx (
txid TEXT NOT NULL,
Expand All @@ -698,16 +698,16 @@ const SORTITION_DB_SCHEMA_4: &'static [&'static str] = &[

/// The changes for version five *just* replace the existing epochs table
/// by deleting all the current entries and inserting the new epochs definition.
const SORTITION_DB_SCHEMA_5: &'static [&'static str] = &[r#"
const SORTITION_DB_SCHEMA_5: &[&str] = &[r#"
DELETE FROM epochs;"#];

const SORTITION_DB_SCHEMA_6: &'static [&'static str] = &[r#"
const SORTITION_DB_SCHEMA_6: &[&str] = &[r#"
DELETE FROM epochs;"#];

const SORTITION_DB_SCHEMA_7: &'static [&'static str] = &[r#"
const SORTITION_DB_SCHEMA_7: &[&str] = &[r#"
DELETE FROM epochs;"#];

const SORTITION_DB_SCHEMA_8: &'static [&'static str] = &[
const SORTITION_DB_SCHEMA_8: &[&str] = &[
r#"DELETE FROM epochs;"#,
r#"DROP INDEX IF EXISTS index_user_burn_support_txid;"#,
r#"DROP INDEX IF EXISTS index_user_burn_support_sortition_id_vtxindex;"#,
Expand Down Expand Up @@ -751,11 +751,11 @@ const SORTITION_DB_SCHEMA_8: &'static [&'static str] = &[
);"#,
];

static SORTITION_DB_SCHEMA_9: &[&'static str] =
static SORTITION_DB_SCHEMA_9: &[&str] =
&[r#"ALTER TABLE block_commits ADD punished TEXT DEFAULT NULL;"#];

const LAST_SORTITION_DB_INDEX: &'static str = "index_block_commits_by_sender";
const SORTITION_DB_INDEXES: &'static [&'static str] = &[
const LAST_SORTITION_DB_INDEX: &str = "index_block_commits_by_sender";
const SORTITION_DB_INDEXES: &[&str] = &[
"CREATE INDEX IF NOT EXISTS snapshots_block_hashes ON snapshots(block_height,index_root,winning_stacks_block_hash);",
"CREATE INDEX IF NOT EXISTS snapshots_block_stacks_hashes ON snapshots(num_sortitions,index_root,winning_stacks_block_hash);",
"CREATE INDEX IF NOT EXISTS snapshots_block_heights ON snapshots(burn_header_hash,block_height);",
Expand Down
22 changes: 11 additions & 11 deletions stackslib/src/chainstate/burn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ impl SortitionHash {
}

impl Opcodes {
const HTTP_BLOCK_COMMIT: &'static str = "block_commit";
const HTTP_KEY_REGISTER: &'static str = "key_register";
const HTTP_BURN_SUPPORT: &'static str = "burn_support";
const HTTP_STACK_STX: &'static str = "stack_stx";
const HTTP_PRE_STX: &'static str = "pre_stx";
const HTTP_TRANSFER_STX: &'static str = "transfer_stx";
const HTTP_DELEGATE_STX: &'static str = "delegate_stx";
const HTTP_PEG_IN: &'static str = "peg_in";
const HTTP_PEG_OUT_REQUEST: &'static str = "peg_out_request";
const HTTP_PEG_OUT_FULFILL: &'static str = "peg_out_fulfill";
const HTTP_VOTE_FOR_AGGREGATE_KEY: &'static str = "vote_for_aggregate_key";
const HTTP_BLOCK_COMMIT: &str = "block_commit";
const HTTP_KEY_REGISTER: &str = "key_register";
const HTTP_BURN_SUPPORT: &str = "burn_support";
const HTTP_STACK_STX: &str = "stack_stx";
const HTTP_PRE_STX: &str = "pre_stx";
const HTTP_TRANSFER_STX: &str = "transfer_stx";
const HTTP_DELEGATE_STX: &str = "delegate_stx";
const HTTP_PEG_IN: &str = "peg_in";
const HTTP_PEG_OUT_REQUEST: &str = "peg_out_request";
const HTTP_PEG_OUT_FULFILL: &str = "peg_out_fulfill";
const HTTP_VOTE_FOR_AGGREGATE_KEY: &str = "vote_for_aggregate_key";

pub fn to_http_str(&self) -> &'static str {
match self {
Expand Down
6 changes: 3 additions & 3 deletions stackslib/src/chainstate/nakamoto/staging_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl fmt::Display for NakamotoBlockObtainMethod {
}
}

pub const NAKAMOTO_STAGING_DB_SCHEMA_1: &'static [&'static str] = &[
pub const NAKAMOTO_STAGING_DB_SCHEMA_1: &[&str] = &[
r#"
-- Table for staging nakamoto blocks
CREATE TABLE nakamoto_staging_blocks (
Expand Down Expand Up @@ -102,7 +102,7 @@ pub const NAKAMOTO_STAGING_DB_SCHEMA_1: &'static [&'static str] = &[
r#"CREATE INDEX nakamoto_staging_blocks_by_tenure_start_block ON nakamoto_staging_blocks(is_tenure_start,consensus_hash);"#,
];

pub const NAKAMOTO_STAGING_DB_SCHEMA_2: &'static [&'static str] = &[
pub const NAKAMOTO_STAGING_DB_SCHEMA_2: &[&str] = &[
r#"
DROP TABLE nakamoto_staging_blocks;
"#,
Expand Down Expand Up @@ -155,7 +155,7 @@ pub const NAKAMOTO_STAGING_DB_SCHEMA_2: &'static [&'static str] = &[
r#"INSERT INTO db_version (version) VALUES (2)"#,
];

pub const NAKAMOTO_STAGING_DB_SCHEMA_3: &'static [&'static str] = &[
pub const NAKAMOTO_STAGING_DB_SCHEMA_3: &[&str] = &[
r#"CREATE INDEX nakamoto_staging_blocks_by_obtain_method ON nakamoto_staging_blocks(consensus_hash,obtain_method);"#,
r#"UPDATE db_version SET version = 3"#,
];
Expand Down
6 changes: 3 additions & 3 deletions stackslib/src/chainstate/nakamoto/tenure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ use crate::util_lib::db::{
FromRow,
};

pub static NAKAMOTO_TENURES_SCHEMA_1: &'static str = r#"
pub static NAKAMOTO_TENURES_SCHEMA_1: &str = r#"
CREATE TABLE nakamoto_tenures (
-- consensus hash of start-tenure block (i.e. the consensus hash of the sortition in which the miner's block-commit
-- was mined)
Expand Down Expand Up @@ -157,7 +157,7 @@ pub static NAKAMOTO_TENURES_SCHEMA_1: &'static str = r#"
CREATE INDEX nakamoto_tenures_by_parent ON nakamoto_tenures(tenure_id_consensus_hash,prev_tenure_id_consensus_hash);
"#;

pub static NAKAMOTO_TENURES_SCHEMA_2: &'static str = r#"
pub static NAKAMOTO_TENURES_SCHEMA_2: &str = r#"
-- Drop the nakamoto_tenures table if it exists
DROP TABLE IF EXISTS nakamoto_tenures;

Expand Down Expand Up @@ -197,7 +197,7 @@ pub static NAKAMOTO_TENURES_SCHEMA_2: &'static str = r#"
CREATE INDEX nakamoto_tenures_by_parent ON nakamoto_tenures(tenure_id_consensus_hash,prev_tenure_id_consensus_hash);
"#;

pub static NAKAMOTO_TENURES_SCHEMA_3: &'static str = r#"
pub static NAKAMOTO_TENURES_SCHEMA_3: &str = r#"
-- Drop the nakamoto_tenures table if it exists
DROP TABLE IF EXISTS nakamoto_tenures;

Expand Down
66 changes: 33 additions & 33 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,48 +61,48 @@ use crate::core::{
use crate::util_lib::boot;
use crate::util_lib::strings::VecDisplay;

const BOOT_CODE_POX_BODY: &'static str = std::include_str!("pox.clar");
const BOOT_CODE_POX_TESTNET_CONSTS: &'static str = std::include_str!("pox-testnet.clar");
const BOOT_CODE_POX_MAINNET_CONSTS: &'static str = std::include_str!("pox-mainnet.clar");
pub const BOOT_CODE_LOCKUP: &'static str = std::include_str!("lockup.clar");
pub const BOOT_CODE_COSTS: &'static str = std::include_str!("costs.clar");
pub const BOOT_CODE_COSTS_2: &'static str = std::include_str!("costs-2.clar");
pub const BOOT_CODE_COSTS_3: &'static str = std::include_str!("costs-3.clar");
pub const BOOT_CODE_COSTS_2_TESTNET: &'static str = std::include_str!("costs-2-testnet.clar");
pub const BOOT_CODE_COST_VOTING_MAINNET: &'static str = std::include_str!("cost-voting.clar");
pub const BOOT_CODE_BNS: &'static str = std::include_str!("bns.clar");
pub const BOOT_CODE_GENESIS: &'static str = std::include_str!("genesis.clar");
pub const POX_1_NAME: &'static str = "pox";
pub const POX_2_NAME: &'static str = "pox-2";
pub const POX_3_NAME: &'static str = "pox-3";
pub const POX_4_NAME: &'static str = "pox-4";
pub const SIGNERS_NAME: &'static str = "signers";
pub const SIGNERS_VOTING_NAME: &'static str = "signers-voting";
const BOOT_CODE_POX_BODY: &str = std::include_str!("pox.clar");
const BOOT_CODE_POX_TESTNET_CONSTS: &str = std::include_str!("pox-testnet.clar");
const BOOT_CODE_POX_MAINNET_CONSTS: &str = std::include_str!("pox-mainnet.clar");
pub const BOOT_CODE_LOCKUP: &str = std::include_str!("lockup.clar");
pub const BOOT_CODE_COSTS: &str = std::include_str!("costs.clar");
pub const BOOT_CODE_COSTS_2: &str = std::include_str!("costs-2.clar");
pub const BOOT_CODE_COSTS_3: &str = std::include_str!("costs-3.clar");
pub const BOOT_CODE_COSTS_2_TESTNET: &str = std::include_str!("costs-2-testnet.clar");
pub const BOOT_CODE_COST_VOTING_MAINNET: &str = std::include_str!("cost-voting.clar");
pub const BOOT_CODE_BNS: &str = std::include_str!("bns.clar");
pub const BOOT_CODE_GENESIS: &str = std::include_str!("genesis.clar");
pub const POX_1_NAME: &str = "pox";
pub const POX_2_NAME: &str = "pox-2";
pub const POX_3_NAME: &str = "pox-3";
pub const POX_4_NAME: &str = "pox-4";
pub const SIGNERS_NAME: &str = "signers";
pub const SIGNERS_VOTING_NAME: &str = "signers-voting";
pub const SIGNERS_VOTING_FUNCTION_NAME: &str = "vote-for-aggregate-public-key";
/// This is the name of a variable in the `.signers` contract which tracks the most recently updated
/// reward cycle number.
pub const SIGNERS_UPDATE_STATE: &'static str = "last-set-cycle";
pub const SIGNERS_UPDATE_STATE: &str = "last-set-cycle";
pub const SIGNERS_MAX_LIST_SIZE: usize = 4000;
pub const SIGNERS_PK_LEN: usize = 33;

const POX_2_BODY: &'static str = std::include_str!("pox-2.clar");
const POX_3_BODY: &'static str = std::include_str!("pox-3.clar");
const POX_4_BODY: &'static str = std::include_str!("pox-4.clar");
pub const SIGNERS_BODY: &'static str = std::include_str!("signers.clar");
pub const SIGNERS_DB_0_BODY: &'static str = std::include_str!("signers-0-xxx.clar");
pub const SIGNERS_DB_1_BODY: &'static str = std::include_str!("signers-1-xxx.clar");
pub const SIGNERS_VOTING_BODY: &'static str = std::include_str!("signers-voting.clar");

pub const COSTS_1_NAME: &'static str = "costs";
pub const COSTS_2_NAME: &'static str = "costs-2";
pub const COSTS_3_NAME: &'static str = "costs-3";
const POX_2_BODY: &str = std::include_str!("pox-2.clar");
const POX_3_BODY: &str = std::include_str!("pox-3.clar");
const POX_4_BODY: &str = std::include_str!("pox-4.clar");
pub const SIGNERS_BODY: &str = std::include_str!("signers.clar");
pub const SIGNERS_DB_0_BODY: &str = std::include_str!("signers-0-xxx.clar");
pub const SIGNERS_DB_1_BODY: &str = std::include_str!("signers-1-xxx.clar");
pub const SIGNERS_VOTING_BODY: &str = std::include_str!("signers-voting.clar");

pub const COSTS_1_NAME: &str = "costs";
pub const COSTS_2_NAME: &str = "costs-2";
pub const COSTS_3_NAME: &str = "costs-3";
/// This contract name is used in testnet **only** to lookup an initial
/// setting for the pox-4 aggregate key. This contract should contain a `define-read-only`
/// function called `aggregate-key` with zero arguments which returns a (buff 33)
pub const BOOT_TEST_POX_4_AGG_KEY_CONTRACT: &'static str = "pox-4-agg-test-booter";
pub const BOOT_TEST_POX_4_AGG_KEY_FNAME: &'static str = "aggregate-key";
pub const BOOT_TEST_POX_4_AGG_KEY_CONTRACT: &str = "pox-4-agg-test-booter";
pub const BOOT_TEST_POX_4_AGG_KEY_FNAME: &str = "aggregate-key";

pub const MINERS_NAME: &'static str = "miners";
pub const MINERS_NAME: &str = "miners";

pub mod docs;

Expand Down Expand Up @@ -237,7 +237,7 @@ pub struct RewardSetData {
pub reward_set: RewardSet,
pub cycle_number: u64,
}
const POX_CYCLE_START_HANDLED_VALUE: &'static str = "1";
const POX_CYCLE_START_HANDLED_VALUE: &str = "1";

impl PoxStartCycleInfo {
pub fn serialize(&self) -> String {
Expand Down
Loading