mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-09 15:28:01 -05:00
chore: set clippy check for const fn to warn (#15777)
This commit is contained in:
@@ -213,7 +213,7 @@ manual_clamp = "warn"
|
||||
manual_is_variant_and = "warn"
|
||||
manual_string_new = "warn"
|
||||
match_same_arms = "warn"
|
||||
missing-const-for-fn = "allow" # TODO: https://github.com/rust-lang/rust-clippy/issues/14020
|
||||
missing-const-for-fn = "warn"
|
||||
mutex_integer = "warn"
|
||||
naive_bytecount = "warn"
|
||||
needless_bitwise_bool = "warn"
|
||||
|
||||
@@ -96,7 +96,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
}
|
||||
|
||||
/// Returns the default KZG settings
|
||||
fn kzg_settings(&self) -> eyre::Result<EnvKzgSettings> {
|
||||
const fn kzg_settings(&self) -> eyre::Result<EnvKzgSettings> {
|
||||
Ok(EnvKzgSettings::Default)
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
Ok(())
|
||||
}
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
Some(&self.env.chain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
Ok(())
|
||||
}
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
Some(&self.env.chain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
Ok(())
|
||||
}
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
Some(&self.env.chain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
Ok(())
|
||||
}
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
Some(&self.env.chain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
}
|
||||
}
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
match &self.command {
|
||||
Subcommands::Execution(command) => command.chain_spec(),
|
||||
Subcommands::Merkle(command) => command.chain_spec(),
|
||||
|
||||
@@ -33,7 +33,7 @@ impl CliRunner {
|
||||
}
|
||||
|
||||
/// Create a new [`CliRunner`] from a provided tokio [`Runtime`](tokio::runtime::Runtime).
|
||||
pub fn from_runtime(tokio_runtime: tokio::runtime::Runtime) -> Self {
|
||||
pub const fn from_runtime(tokio_runtime: tokio::runtime::Runtime) -> Self {
|
||||
Self { tokio_runtime }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ pub struct PickNextBlockProducer {}
|
||||
|
||||
impl PickNextBlockProducer {
|
||||
/// Create a new `PickNextBlockProducer` action
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ impl<I> Setup<I> {
|
||||
}
|
||||
|
||||
/// Set the genesis block
|
||||
pub fn with_genesis(mut self, genesis: Genesis) -> Self {
|
||||
pub const fn with_genesis(mut self, genesis: Genesis) -> Self {
|
||||
self.genesis = Some(genesis);
|
||||
self
|
||||
}
|
||||
@@ -103,13 +103,13 @@ impl<I> Setup<I> {
|
||||
}
|
||||
|
||||
/// Set the network configuration
|
||||
pub fn with_network(mut self, network: NetworkSetup) -> Self {
|
||||
pub const fn with_network(mut self, network: NetworkSetup) -> Self {
|
||||
self.network = network;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set dev mode
|
||||
pub fn with_dev_mode(mut self, is_dev: bool) -> Self {
|
||||
pub const fn with_dev_mode(mut self, is_dev: bool) -> Self {
|
||||
self.is_dev = is_dev;
|
||||
self
|
||||
}
|
||||
@@ -240,12 +240,12 @@ pub struct NetworkSetup {
|
||||
|
||||
impl NetworkSetup {
|
||||
/// Create a new network setup with a single node
|
||||
pub fn single_node() -> Self {
|
||||
pub const fn single_node() -> Self {
|
||||
Self { node_count: 1 }
|
||||
}
|
||||
|
||||
/// Create a new network setup with multiple nodes
|
||||
pub fn multi_node(count: usize) -> Self {
|
||||
pub const fn multi_node(count: usize) -> Self {
|
||||
Self { node_count: count }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ impl TreeConfig {
|
||||
}
|
||||
|
||||
/// Whether or not to use state root task
|
||||
pub fn use_state_root_task(&self) -> bool {
|
||||
pub const fn use_state_root_task(&self) -> bool {
|
||||
self.has_enough_parallelism && !self.legacy_state_root
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ impl ForkchoiceStateTracker {
|
||||
///
|
||||
/// If the status is `VALID`, we also update the last valid forkchoice state and set the
|
||||
/// `sync_target` to `None`, since we're now fully synced.
|
||||
pub fn set_latest(&mut self, state: ForkchoiceState, status: ForkchoiceStatus) {
|
||||
pub const fn set_latest(&mut self, state: ForkchoiceState, status: ForkchoiceStatus) {
|
||||
if status.is_valid() {
|
||||
self.set_valid(state);
|
||||
} else if status.is_syncing() {
|
||||
@@ -30,7 +30,7 @@ impl ForkchoiceStateTracker {
|
||||
self.latest = Some(received);
|
||||
}
|
||||
|
||||
fn set_valid(&mut self, state: ForkchoiceState) {
|
||||
const fn set_valid(&mut self, state: ForkchoiceState) {
|
||||
// we no longer need to sync to this state.
|
||||
self.last_syncing = None;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the handler
|
||||
pub fn handler_mut(&mut self) -> &mut T {
|
||||
pub const fn handler_mut(&mut self) -> &mut T {
|
||||
&mut self.handler
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ impl<T, S, D> EngineHandler<T, S, D> {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the request handler.
|
||||
pub fn handler_mut(&mut self) -> &mut T {
|
||||
pub const fn handler_mut(&mut self) -> &mut T {
|
||||
&mut self.handler
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,7 +518,7 @@ impl SavedCache {
|
||||
}
|
||||
|
||||
/// Returns the [`ProviderCaches`] belonging to the tracked hash.
|
||||
pub(crate) fn cache(&self) -> &ProviderCaches {
|
||||
pub(crate) const fn cache(&self) -> &ProviderCaches {
|
||||
&self.caches
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ impl<N: NodePrimitives> TreeState<N> {
|
||||
}
|
||||
|
||||
/// Updates the canonical head to the given block.
|
||||
fn set_canonical_head(&mut self, new_head: BlockNumHash) {
|
||||
const fn set_canonical_head(&mut self, new_head: BlockNumHash) {
|
||||
self.current_canonical_head = new_head;
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ pub struct StateProviderBuilder<N: NodePrimitives, P> {
|
||||
impl<N: NodePrimitives, P> StateProviderBuilder<N, P> {
|
||||
/// Creates a new state provider from the provider factory, historical block hash and optional
|
||||
/// overlaid blocks.
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
provider_factory: P,
|
||||
historical: B256,
|
||||
overlay: Option<Vec<ExecutedBlockWithTrieUpdates<N>>>,
|
||||
@@ -3042,13 +3042,13 @@ impl PersistingKind {
|
||||
///
|
||||
/// We only run the parallel state root if we are not currently persisting any blocks or
|
||||
/// persisting blocks that are all ancestors of the one we are calculating the state root for.
|
||||
pub fn can_run_parallel_state_root(&self) -> bool {
|
||||
pub const fn can_run_parallel_state_root(&self) -> bool {
|
||||
matches!(self, Self::NotPersisting | Self::PersistingDescendant)
|
||||
}
|
||||
|
||||
/// Returns true if the blocks are currently being persisted and the input block is a
|
||||
/// descendant.
|
||||
pub fn is_descendant(&self) -> bool {
|
||||
pub const fn is_descendant(&self) -> bool {
|
||||
matches!(self, Self::PersistingDescendant)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl WorkloadExecutor {
|
||||
}
|
||||
|
||||
/// Returns the handle to the tokio runtime
|
||||
pub(super) fn handle(&self) -> &Handle {
|
||||
pub(super) const fn handle(&self) -> &Handle {
|
||||
&self.inner.handle
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ impl WorkloadExecutor {
|
||||
|
||||
/// Returns access to the rayon pool
|
||||
#[expect(unused)]
|
||||
pub(super) fn rayon_pool(&self) -> &Arc<rayon::ThreadPool> {
|
||||
pub(super) const fn rayon_pool(&self) -> &Arc<rayon::ThreadPool> {
|
||||
&self.inner.rayon_pool
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ struct ProofSequencer {
|
||||
|
||||
impl ProofSequencer {
|
||||
/// Gets the next sequence number and increments the counter
|
||||
fn next_sequence(&mut self) -> u64 {
|
||||
const fn next_sequence(&mut self) -> u64 {
|
||||
let seq = self.next_sequence;
|
||||
self.next_sequence += 1;
|
||||
seq
|
||||
@@ -254,7 +254,7 @@ enum PendingMultiproofTask<Factory> {
|
||||
|
||||
impl<Factory> PendingMultiproofTask<Factory> {
|
||||
/// Returns the proof sequence number of the task.
|
||||
fn proof_sequence_number(&self) -> u64 {
|
||||
const fn proof_sequence_number(&self) -> u64 {
|
||||
match self {
|
||||
Self::Storage(input) => input.proof_sequence_number,
|
||||
Self::Regular(input) => input.proof_sequence_number,
|
||||
|
||||
@@ -41,7 +41,7 @@ where
|
||||
BPF::StorageNodeProvider: BlindedProvider + Send + Sync,
|
||||
{
|
||||
/// Creates a new sparse trie task.
|
||||
pub(super) fn new(
|
||||
pub(super) const fn new(
|
||||
executor: WorkloadExecutor,
|
||||
updates: mpsc::Receiver<SparseTrieUpdate>,
|
||||
blinded_provider_factory: BPF,
|
||||
|
||||
@@ -39,7 +39,7 @@ pub struct EraClient<Http> {
|
||||
|
||||
impl<Http: HttpClient + Clone> EraClient<Http> {
|
||||
/// Constructs [`EraClient`] using `client` to download from `url` into `folder`.
|
||||
pub fn new(client: Http, url: Url, folder: Box<Path>) -> Self {
|
||||
pub const fn new(client: Http, url: Url, folder: Box<Path>) -> Self {
|
||||
Self { client, url, folder }
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ impl Default for EraStreamConfig {
|
||||
|
||||
impl EraStreamConfig {
|
||||
/// The maximum amount of downloaded ERA1 files kept in the download directory.
|
||||
pub fn with_max_files(mut self, max_files: usize) -> Self {
|
||||
pub const fn with_max_files(mut self, max_files: usize) -> Self {
|
||||
self.max_files = max_files;
|
||||
self
|
||||
}
|
||||
|
||||
/// The maximum amount of downloads happening at the same time.
|
||||
pub fn with_max_concurrent_downloads(mut self, max_concurrent_downloads: usize) -> Self {
|
||||
pub const fn with_max_concurrent_downloads(mut self, max_concurrent_downloads: usize) -> Self {
|
||||
self.max_concurrent_downloads = max_concurrent_downloads;
|
||||
self
|
||||
}
|
||||
@@ -216,7 +216,7 @@ impl<Http: HttpClient + Clone + Send + Sync + 'static + Unpin> Stream for Starti
|
||||
}
|
||||
|
||||
impl<Http> StartingStream<Http> {
|
||||
fn downloaded(&mut self) {
|
||||
const fn downloaded(&mut self) {
|
||||
self.downloading = self.downloading.saturating_sub(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ pub struct Header {
|
||||
|
||||
impl Header {
|
||||
/// Create a new header with the specified type and length
|
||||
pub fn new(header_type: [u8; 2], length: u32) -> Self {
|
||||
pub const fn new(header_type: [u8; 2], length: u32) -> Self {
|
||||
Self { header_type, length, reserved: 0 }
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ pub struct Entry {
|
||||
|
||||
impl Entry {
|
||||
/// Create a new entry
|
||||
pub fn new(entry_type: [u8; 2], data: Vec<u8>) -> Self {
|
||||
pub const fn new(entry_type: [u8; 2], data: Vec<u8>) -> Self {
|
||||
Self { entry_type, data }
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub struct Era1File {
|
||||
|
||||
impl Era1File {
|
||||
/// Create a new [`Era1File`]
|
||||
pub fn new(group: Era1Group, id: Era1Id) -> Self {
|
||||
pub const fn new(group: Era1Group, id: Era1Id) -> Self {
|
||||
Self { version: Version, group, id }
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ pub struct Era1Group {
|
||||
|
||||
impl Era1Group {
|
||||
/// Create a new [`Era1Group`]
|
||||
pub fn new(blocks: Vec<BlockTuple>, accumulator: Accumulator, block_index: BlockIndex) -> Self {
|
||||
pub const fn new(
|
||||
blocks: Vec<BlockTuple>,
|
||||
accumulator: Accumulator,
|
||||
block_index: BlockIndex,
|
||||
) -> Self {
|
||||
Self { blocks, accumulator, block_index, other_entries: Vec::new() }
|
||||
}
|
||||
/// Add another entry to this group
|
||||
@@ -56,7 +60,7 @@ pub struct BlockIndex {
|
||||
|
||||
impl BlockIndex {
|
||||
/// Create a new [`BlockIndex`]
|
||||
pub fn new(starting_number: BlockNumber, offsets: Vec<i64>) -> Self {
|
||||
pub const fn new(starting_number: BlockNumber, offsets: Vec<i64>) -> Self {
|
||||
Self { starting_number, offsets }
|
||||
}
|
||||
|
||||
@@ -165,7 +169,7 @@ impl Era1Id {
|
||||
}
|
||||
|
||||
/// Add a hash identifier to [`Era1Id`]
|
||||
pub fn with_hash(mut self, hash: [u8; 4]) -> Self {
|
||||
pub const fn with_hash(mut self, hash: [u8; 4]) -> Self {
|
||||
self.hash = Some(hash);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ pub struct SnappyRlpCodec<T> {
|
||||
|
||||
impl<T> SnappyRlpCodec<T> {
|
||||
/// Create a new codec for the given type
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self { _phantom: PhantomData }
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ pub trait DecodeCompressed {
|
||||
|
||||
impl CompressedHeader {
|
||||
/// Create a new [`CompressedHeader`] from compressed data
|
||||
pub fn new(data: Vec<u8>) -> Self {
|
||||
pub const fn new(data: Vec<u8>) -> Self {
|
||||
Self { data }
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ pub struct CompressedBody {
|
||||
|
||||
impl CompressedBody {
|
||||
/// Create a new [`CompressedBody`] from compressed data
|
||||
pub fn new(data: Vec<u8>) -> Self {
|
||||
pub const fn new(data: Vec<u8>) -> Self {
|
||||
Self { data }
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ pub struct CompressedReceipts {
|
||||
|
||||
impl CompressedReceipts {
|
||||
/// Create a new [`CompressedReceipts`] from compressed data
|
||||
pub fn new(data: Vec<u8>) -> Self {
|
||||
pub const fn new(data: Vec<u8>) -> Self {
|
||||
Self { data }
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ pub struct TotalDifficulty {
|
||||
|
||||
impl TotalDifficulty {
|
||||
/// Create a new [`TotalDifficulty`] from a U256 value
|
||||
pub fn new(value: U256) -> Self {
|
||||
pub const fn new(value: U256) -> Self {
|
||||
Self { value }
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ pub struct Accumulator {
|
||||
|
||||
impl Accumulator {
|
||||
/// Create a new [`Accumulator`] from a root hash
|
||||
pub fn new(root: B256) -> Self {
|
||||
pub const fn new(root: B256) -> Self {
|
||||
Self { root }
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ pub struct BlockTuple {
|
||||
|
||||
impl BlockTuple {
|
||||
/// Create a new [`BlockTuple`]
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
header: CompressedHeader,
|
||||
body: CompressedBody,
|
||||
receipts: CompressedReceipts,
|
||||
|
||||
@@ -118,7 +118,7 @@ impl Transaction {
|
||||
}
|
||||
|
||||
/// This sets the transaction's nonce.
|
||||
pub fn set_nonce(&mut self, nonce: u64) {
|
||||
pub const fn set_nonce(&mut self, nonce: u64) {
|
||||
match self {
|
||||
Self::Legacy(tx) => tx.nonce = nonce,
|
||||
Self::Eip2930(tx) => tx.nonce = nonce,
|
||||
@@ -129,7 +129,7 @@ impl Transaction {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn input_mut(&mut self) -> &mut Bytes {
|
||||
const fn input_mut(&mut self) -> &mut Bytes {
|
||||
match self {
|
||||
Self::Legacy(tx) => &mut tx.input,
|
||||
Self::Eip2930(tx) => &mut tx.input,
|
||||
@@ -367,7 +367,7 @@ impl TransactionSigned {
|
||||
}
|
||||
|
||||
/// Returns the signature of the transaction
|
||||
pub fn signature(&self) -> &Signature {
|
||||
pub const fn signature(&self) -> &Signature {
|
||||
&self.signature
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,7 @@ impl TransactionSigned {
|
||||
|
||||
/// Provides mutable access to the transaction.
|
||||
#[cfg(feature = "test-utils")]
|
||||
pub fn transaction_mut(&mut self) -> &mut Transaction {
|
||||
pub const fn transaction_mut(&mut self) -> &mut Transaction {
|
||||
&mut self.transaction
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ impl<N: NodePrimitives> Chain<N> {
|
||||
}
|
||||
|
||||
/// Get mutable execution outcome of this chain
|
||||
pub fn execution_outcome_mut(&mut self) -> &mut ExecutionOutcome<N::Receipt> {
|
||||
pub const fn execution_outcome_mut(&mut self) -> &mut ExecutionOutcome<N::Receipt> {
|
||||
&mut self.execution_outcome
|
||||
}
|
||||
|
||||
|
||||
@@ -158,12 +158,12 @@ impl<T> ExecutionOutcome<T> {
|
||||
}
|
||||
|
||||
/// Returns mutable revm bundle state.
|
||||
pub fn state_mut(&mut self) -> &mut BundleState {
|
||||
pub const fn state_mut(&mut self) -> &mut BundleState {
|
||||
&mut self.bundle
|
||||
}
|
||||
|
||||
/// Set first block.
|
||||
pub fn set_first_block(&mut self, first_block: BlockNumber) {
|
||||
pub const fn set_first_block(&mut self, first_block: BlockNumber) {
|
||||
self.first_block = first_block;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ impl<T> ExecutionOutcome<T> {
|
||||
}
|
||||
|
||||
/// Returns mutable reference to receipts.
|
||||
pub fn receipts_mut(&mut self) -> &mut Vec<Vec<T>> {
|
||||
pub const fn receipts_mut(&mut self) -> &mut Vec<Vec<T>> {
|
||||
&mut self.receipts
|
||||
}
|
||||
|
||||
|
||||
@@ -149,85 +149,91 @@ pub struct Discv4ConfigBuilder {
|
||||
|
||||
impl Discv4ConfigBuilder {
|
||||
/// Whether to enable the incoming packet filter.
|
||||
pub fn enable_packet_filter(&mut self) -> &mut Self {
|
||||
pub const fn enable_packet_filter(&mut self) -> &mut Self {
|
||||
self.config.enable_packet_filter = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the channel size for incoming messages
|
||||
pub fn udp_ingress_message_buffer(&mut self, udp_ingress_message_buffer: usize) -> &mut Self {
|
||||
pub const fn udp_ingress_message_buffer(
|
||||
&mut self,
|
||||
udp_ingress_message_buffer: usize,
|
||||
) -> &mut Self {
|
||||
self.config.udp_ingress_message_buffer = udp_ingress_message_buffer;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the channel size for outgoing messages
|
||||
pub fn udp_egress_message_buffer(&mut self, udp_egress_message_buffer: usize) -> &mut Self {
|
||||
pub const fn udp_egress_message_buffer(
|
||||
&mut self,
|
||||
udp_egress_message_buffer: usize,
|
||||
) -> &mut Self {
|
||||
self.config.udp_egress_message_buffer = udp_egress_message_buffer;
|
||||
self
|
||||
}
|
||||
|
||||
/// The number of allowed request failures for `findNode` requests.
|
||||
pub fn max_find_node_failures(&mut self, max_find_node_failures: u8) -> &mut Self {
|
||||
pub const fn max_find_node_failures(&mut self, max_find_node_failures: u8) -> &mut Self {
|
||||
self.config.max_find_node_failures = max_find_node_failures;
|
||||
self
|
||||
}
|
||||
|
||||
/// The time between pings to ensure connectivity amongst connected nodes.
|
||||
pub fn ping_interval(&mut self, interval: Duration) -> &mut Self {
|
||||
pub const fn ping_interval(&mut self, interval: Duration) -> &mut Self {
|
||||
self.config.ping_interval = interval;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the timeout after which requests are considered timed out
|
||||
pub fn request_timeout(&mut self, duration: Duration) -> &mut Self {
|
||||
pub const fn request_timeout(&mut self, duration: Duration) -> &mut Self {
|
||||
self.config.request_timeout = duration;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the expiration duration for pings
|
||||
pub fn ping_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
pub const fn ping_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
self.config.ping_expiration = duration;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the expiration duration for enr requests
|
||||
pub fn enr_request_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
pub const fn enr_request_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
self.config.enr_expiration = duration;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the expiration duration for lookup neighbor requests
|
||||
pub fn lookup_neighbours_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
pub const fn lookup_neighbours_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
self.config.neighbours_expiration = duration;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the expiration duration for a bond with a peer
|
||||
pub fn bond_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
pub const fn bond_expiration(&mut self, duration: Duration) -> &mut Self {
|
||||
self.config.bond_expiration = duration;
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether to discover random nodes in the DHT.
|
||||
pub fn enable_dht_random_walk(&mut self, enable_dht_random_walk: bool) -> &mut Self {
|
||||
pub const fn enable_dht_random_walk(&mut self, enable_dht_random_walk: bool) -> &mut Self {
|
||||
self.config.enable_dht_random_walk = enable_dht_random_walk;
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether to automatically lookup
|
||||
pub fn enable_lookup(&mut self, enable_lookup: bool) -> &mut Self {
|
||||
pub const fn enable_lookup(&mut self, enable_lookup: bool) -> &mut Self {
|
||||
self.config.enable_lookup = enable_lookup;
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether to enforce expiration timestamps in messages.
|
||||
pub fn enable_eip868(&mut self, enable_eip868: bool) -> &mut Self {
|
||||
pub const fn enable_eip868(&mut self, enable_eip868: bool) -> &mut Self {
|
||||
self.config.enable_eip868 = enable_eip868;
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether to enable EIP-868
|
||||
pub fn enforce_expiration_timestamps(
|
||||
pub const fn enforce_expiration_timestamps(
|
||||
&mut self,
|
||||
enforce_expiration_timestamps: bool,
|
||||
) -> &mut Self {
|
||||
@@ -265,7 +271,7 @@ impl Discv4ConfigBuilder {
|
||||
}
|
||||
|
||||
/// Sets the lookup interval duration.
|
||||
pub fn lookup_interval(&mut self, lookup_interval: Duration) -> &mut Self {
|
||||
pub const fn lookup_interval(&mut self, lookup_interval: Duration) -> &mut Self {
|
||||
self.config.lookup_interval = lookup_interval;
|
||||
self
|
||||
}
|
||||
@@ -273,7 +279,7 @@ impl Discv4ConfigBuilder {
|
||||
/// Set the default duration for which nodes are banned for. This timeouts are checked every 5
|
||||
/// minutes, so the precision will be to the nearest 5 minutes. If set to `None`, bans from
|
||||
/// the filter will last indefinitely. Default is 1 hour.
|
||||
pub fn ban_duration(&mut self, ban_duration: Option<Duration>) -> &mut Self {
|
||||
pub const fn ban_duration(&mut self, ban_duration: Option<Duration>) -> &mut Self {
|
||||
self.config.ban_duration = ban_duration;
|
||||
self
|
||||
}
|
||||
@@ -291,13 +297,16 @@ impl Discv4ConfigBuilder {
|
||||
}
|
||||
|
||||
/// Configures if and how the external IP of the node should be resolved.
|
||||
pub fn external_ip_resolver(&mut self, external_ip_resolver: Option<NatResolver>) -> &mut Self {
|
||||
pub const fn external_ip_resolver(
|
||||
&mut self,
|
||||
external_ip_resolver: Option<NatResolver>,
|
||||
) -> &mut Self {
|
||||
self.config.external_ip_resolver = external_ip_resolver;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the interval at which the external IP is to be resolved.
|
||||
pub fn resolve_external_ip_interval(
|
||||
pub const fn resolve_external_ip_interval(
|
||||
&mut self,
|
||||
resolve_external_ip_interval: Option<Duration>,
|
||||
) -> &mut Self {
|
||||
|
||||
@@ -652,7 +652,7 @@ impl Discv4Service {
|
||||
|
||||
/// Returns mutable reference to ENR for testing.
|
||||
#[cfg(test)]
|
||||
pub fn local_enr_mut(&mut self) -> &mut NodeRecord {
|
||||
pub const fn local_enr_mut(&mut self) -> &mut NodeRecord {
|
||||
&mut self.local_node_record
|
||||
}
|
||||
|
||||
@@ -2319,7 +2319,7 @@ impl NodeEntry {
|
||||
}
|
||||
|
||||
/// Marks the entry with an established proof and resets the consecutive failure counter.
|
||||
fn establish_proof(&mut self) {
|
||||
const fn establish_proof(&mut self) {
|
||||
self.has_endpoint_proof = true;
|
||||
self.find_node_failures = 0;
|
||||
}
|
||||
@@ -2335,7 +2335,7 @@ impl NodeEntry {
|
||||
}
|
||||
|
||||
/// Increases the failed request counter
|
||||
fn inc_failed_request(&mut self) {
|
||||
const fn inc_failed_request(&mut self) {
|
||||
self.find_node_failures += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ impl<K: EnrKeyUnambiguous> SyncTree<K> {
|
||||
&self.link
|
||||
}
|
||||
|
||||
pub(crate) fn resolved_links_mut(&mut self) -> &mut HashMap<String, LinkEntry<K>> {
|
||||
pub(crate) const fn resolved_links_mut(&mut self) -> &mut HashMap<String, LinkEntry<K>> {
|
||||
&mut self.resolved_links
|
||||
}
|
||||
|
||||
|
||||
@@ -954,7 +954,7 @@ struct HeadersRequestOutcome<H> {
|
||||
// === impl OrderedHeadersResponse ===
|
||||
|
||||
impl<H> HeadersRequestOutcome<H> {
|
||||
fn block_number(&self) -> u64 {
|
||||
const fn block_number(&self) -> u64 {
|
||||
self.request.start.as_number().expect("is number")
|
||||
}
|
||||
}
|
||||
@@ -970,7 +970,7 @@ struct OrderedHeadersResponse<H> {
|
||||
// === impl OrderedHeadersResponse ===
|
||||
|
||||
impl<H> OrderedHeadersResponse<H> {
|
||||
fn block_number(&self) -> u64 {
|
||||
const fn block_number(&self) -> u64 {
|
||||
self.request.start.as_number().expect("is number")
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ impl SyncTargetBlock {
|
||||
///
|
||||
/// If the target block is a hash, this be converted into a `HashAndNumber`, but return `None`.
|
||||
/// The semantics should be equivalent to that of `Option::replace`.
|
||||
fn replace_number(&mut self, number: u64) -> Option<u64> {
|
||||
const fn replace_number(&mut self, number: u64) -> Option<u64> {
|
||||
match self {
|
||||
Self::Hash(hash) => {
|
||||
*self = Self::HashAndNumber { hash: *hash, number };
|
||||
|
||||
@@ -362,7 +362,7 @@ impl ECIES {
|
||||
}
|
||||
|
||||
/// Return the contained remote peer ID.
|
||||
pub fn remote_id(&self) -> PeerId {
|
||||
pub const fn remote_id(&self) -> PeerId {
|
||||
self.remote_id.unwrap()
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ impl ECIES {
|
||||
32
|
||||
}
|
||||
|
||||
pub fn body_len(&self) -> usize {
|
||||
pub const fn body_len(&self) -> usize {
|
||||
let len = self.body_size.unwrap();
|
||||
Self::align_16(len) + 16
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ impl NewPooledTransactionHashes {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to transaction hashes.
|
||||
pub fn hashes_mut(&mut self) -> &mut Vec<B256> {
|
||||
pub const fn hashes_mut(&mut self) -> &mut Vec<B256> {
|
||||
match self {
|
||||
Self::Eth66(msg) => &mut msg.0,
|
||||
Self::Eth68(msg) => &mut msg.hashes,
|
||||
@@ -233,7 +233,7 @@ impl NewPooledTransactionHashes {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner type if this an eth68 announcement.
|
||||
pub fn as_eth68_mut(&mut self) -> Option<&mut NewPooledTransactionHashes68> {
|
||||
pub const fn as_eth68_mut(&mut self) -> Option<&mut NewPooledTransactionHashes68> {
|
||||
match self {
|
||||
Self::Eth66(_) => None,
|
||||
Self::Eth68(msg) => Some(msg),
|
||||
@@ -241,7 +241,7 @@ impl NewPooledTransactionHashes {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner type if this an eth66 announcement.
|
||||
pub fn as_eth66_mut(&mut self) -> Option<&mut NewPooledTransactionHashes66> {
|
||||
pub const fn as_eth66_mut(&mut self) -> Option<&mut NewPooledTransactionHashes66> {
|
||||
match self {
|
||||
Self::Eth66(msg) => Some(msg),
|
||||
Self::Eth68(_) => None,
|
||||
|
||||
@@ -256,7 +256,7 @@ pub enum EthMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
|
||||
|
||||
impl<N: NetworkPrimitives> EthMessage<N> {
|
||||
/// Returns the message's ID.
|
||||
pub fn message_id(&self) -> EthMessageID {
|
||||
pub const fn message_id(&self) -> EthMessageID {
|
||||
match self {
|
||||
Self::Status(_) => EthMessageID::Status,
|
||||
Self::NewBlockHashes(_) => EthMessageID::NewBlockHashes,
|
||||
|
||||
@@ -49,7 +49,7 @@ impl Status {
|
||||
}
|
||||
|
||||
/// Sets the [`EthVersion`] for the status.
|
||||
pub fn set_eth_version(&mut self, version: EthVersion) {
|
||||
pub const fn set_eth_version(&mut self, version: EthVersion) {
|
||||
self.version = version;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ impl Status {
|
||||
}
|
||||
|
||||
/// Converts this [`Status`] into the [Eth69](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7642.md) variant that excludes the total difficulty field.
|
||||
pub fn into_eth69(self) -> StatusEth69 {
|
||||
pub const fn into_eth69(self) -> StatusEth69 {
|
||||
StatusEth69 {
|
||||
version: EthVersion::Eth69,
|
||||
chain: self.chain,
|
||||
|
||||
@@ -70,7 +70,7 @@ where
|
||||
N: NetworkPrimitives,
|
||||
{
|
||||
/// Create a new eth and snap protocol stream
|
||||
pub fn new(stream: S, eth_version: EthVersion) -> Self {
|
||||
pub const fn new(stream: S, eth_version: EthVersion) -> Self {
|
||||
Self { eth_snap: EthSnapStreamInner::new(eth_version), inner: stream }
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ where
|
||||
|
||||
/// Returns mutable access to the underlying stream
|
||||
#[inline]
|
||||
pub fn inner_mut(&mut self) -> &mut S {
|
||||
pub const fn inner_mut(&mut self) -> &mut S {
|
||||
&mut self.inner
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ impl<S, N: NetworkPrimitives> EthStream<S, N> {
|
||||
|
||||
/// Returns mutable access to the underlying stream.
|
||||
#[inline]
|
||||
pub fn inner_mut(&mut self) -> &mut S {
|
||||
pub const fn inner_mut(&mut self) -> &mut S {
|
||||
&mut self.inner
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ impl<St, Primary> RlpxSatelliteStream<St, Primary> {
|
||||
|
||||
/// Returns mutable access to the primary protocol.
|
||||
#[inline]
|
||||
pub fn primary_mut(&mut self) -> &mut Primary {
|
||||
pub const fn primary_mut(&mut self) -> &mut Primary {
|
||||
&mut self.primary.st
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ impl<St, Primary> RlpxSatelliteStream<St, Primary> {
|
||||
|
||||
/// Returns mutable access to the underlying [`P2PStream`].
|
||||
#[inline]
|
||||
pub fn inner_mut(&mut self) -> &mut P2PStream<St> {
|
||||
pub const fn inner_mut(&mut self) -> &mut P2PStream<St> {
|
||||
&mut self.inner.conn
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ impl<S> P2PStream<S> {
|
||||
/// # Panics
|
||||
///
|
||||
/// If the provided capacity is `0`.
|
||||
pub fn set_outgoing_message_buffer_capacity(&mut self, capacity: usize) {
|
||||
pub const fn set_outgoing_message_buffer_capacity(&mut self, capacity: usize) {
|
||||
self.outgoing_message_buffer_capacity = capacity;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ impl Peer {
|
||||
|
||||
/// Resets the reputation of the peer to the default value. This always returns
|
||||
/// [`ReputationChangeOutcome::None`].
|
||||
pub fn reset_reputation(&mut self) -> ReputationChangeOutcome {
|
||||
pub const fn reset_reputation(&mut self) -> ReputationChangeOutcome {
|
||||
self.reputation = DEFAULT_REPUTATION;
|
||||
|
||||
ReputationChangeOutcome::None
|
||||
@@ -120,7 +120,7 @@ impl Peer {
|
||||
|
||||
/// Unbans the peer by resetting its reputation
|
||||
#[inline]
|
||||
pub fn unban(&mut self) {
|
||||
pub const fn unban(&mut self) {
|
||||
self.reputation = DEFAULT_REPUTATION
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ pub enum PeerConnectionState {
|
||||
impl PeerConnectionState {
|
||||
/// Sets the disconnect state
|
||||
#[inline]
|
||||
pub fn disconnect(&mut self) {
|
||||
pub const fn disconnect(&mut self) {
|
||||
match self {
|
||||
Self::In => *self = Self::DisconnectingIn,
|
||||
Self::Out => *self = Self::DisconnectingOut,
|
||||
|
||||
@@ -37,7 +37,7 @@ impl<Tx, Eth, N: NetworkPrimitives> NetworkBuilder<Tx, Eth, N> {
|
||||
}
|
||||
|
||||
/// Returns the mutable network manager.
|
||||
pub fn network_mut(&mut self) -> &mut NetworkManager<N> {
|
||||
pub const fn network_mut(&mut self) -> &mut NetworkManager<N> {
|
||||
&mut self.network
|
||||
}
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ impl PeerState {
|
||||
/// If the state was already marked as `Closing` do nothing.
|
||||
///
|
||||
/// Returns `true` if the peer is ready for another request.
|
||||
fn on_request_finished(&mut self) -> bool {
|
||||
const fn on_request_finished(&mut self) -> bool {
|
||||
if !matches!(self, Self::Closing) {
|
||||
*self = Self::Idle;
|
||||
return true
|
||||
|
||||
@@ -374,7 +374,7 @@ pub struct TxTypesCounter {
|
||||
}
|
||||
|
||||
impl TxTypesCounter {
|
||||
pub(crate) fn increase_by_tx_type(&mut self, tx_type: TxType) {
|
||||
pub(crate) const fn increase_by_tx_type(&mut self, tx_type: TxType) {
|
||||
match tx_type {
|
||||
TxType::Legacy => {
|
||||
self.legacy += 1;
|
||||
|
||||
@@ -285,12 +285,12 @@ impl PeersManager {
|
||||
|
||||
/// Invoked when a previous call to [`Self::on_incoming_pending_session`] succeeded but it was
|
||||
/// rejected.
|
||||
pub(crate) fn on_incoming_pending_session_rejected_internally(&mut self) {
|
||||
pub(crate) const fn on_incoming_pending_session_rejected_internally(&mut self) {
|
||||
self.connection_info.decr_pending_in();
|
||||
}
|
||||
|
||||
/// Invoked when a pending session was closed.
|
||||
pub(crate) fn on_incoming_pending_session_gracefully_closed(&mut self) {
|
||||
pub(crate) const fn on_incoming_pending_session_gracefully_closed(&mut self) {
|
||||
self.connection_info.decr_pending_in()
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ impl PeersManager {
|
||||
///
|
||||
/// If the session was an outgoing connection, this means that the peer initiated a connection
|
||||
/// to us at the same time and this connection is already established.
|
||||
pub(crate) fn on_already_connected(&mut self, direction: Direction) {
|
||||
pub(crate) const fn on_already_connected(&mut self, direction: Direction) {
|
||||
match direction {
|
||||
Direction::Incoming => {
|
||||
// need to decrement the ingoing counter
|
||||
@@ -954,7 +954,7 @@ impl PeersManager {
|
||||
}
|
||||
|
||||
/// Keeps track of network state changes.
|
||||
pub fn on_network_state_change(&mut self, state: NetworkConnectionState) {
|
||||
pub const fn on_network_state_change(&mut self, state: NetworkConnectionState) {
|
||||
self.net_connection_state = state;
|
||||
}
|
||||
|
||||
@@ -964,7 +964,7 @@ impl PeersManager {
|
||||
}
|
||||
|
||||
/// Sets `net_connection_state` to `ShuttingDown`.
|
||||
pub fn on_shutdown(&mut self) {
|
||||
pub const fn on_shutdown(&mut self) {
|
||||
self.net_connection_state = NetworkConnectionState::ShuttingDown;
|
||||
}
|
||||
|
||||
@@ -1081,7 +1081,7 @@ impl ConnectionInfo {
|
||||
self.num_pending_in < self.config.max_inbound
|
||||
}
|
||||
|
||||
fn decr_state(&mut self, state: PeerConnectionState) {
|
||||
const fn decr_state(&mut self, state: PeerConnectionState) {
|
||||
match state {
|
||||
PeerConnectionState::Idle => {}
|
||||
PeerConnectionState::DisconnectingIn | PeerConnectionState::In => self.decr_in(),
|
||||
@@ -1090,35 +1090,35 @@ impl ConnectionInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn decr_out(&mut self) {
|
||||
const fn decr_out(&mut self) {
|
||||
self.num_outbound -= 1;
|
||||
}
|
||||
|
||||
fn inc_out(&mut self) {
|
||||
const fn inc_out(&mut self) {
|
||||
self.num_outbound += 1;
|
||||
}
|
||||
|
||||
fn inc_pending_out(&mut self) {
|
||||
const fn inc_pending_out(&mut self) {
|
||||
self.num_pending_out += 1;
|
||||
}
|
||||
|
||||
fn inc_in(&mut self) {
|
||||
const fn inc_in(&mut self) {
|
||||
self.num_inbound += 1;
|
||||
}
|
||||
|
||||
fn inc_pending_in(&mut self) {
|
||||
const fn inc_pending_in(&mut self) {
|
||||
self.num_pending_in += 1;
|
||||
}
|
||||
|
||||
fn decr_in(&mut self) {
|
||||
const fn decr_in(&mut self) {
|
||||
self.num_inbound -= 1;
|
||||
}
|
||||
|
||||
fn decr_pending_out(&mut self) {
|
||||
const fn decr_pending_out(&mut self) {
|
||||
self.num_pending_out -= 1;
|
||||
}
|
||||
|
||||
fn decr_pending_in(&mut self) {
|
||||
const fn decr_pending_in(&mut self) {
|
||||
self.num_pending_in -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ impl<N: NetworkPrimitives> ActiveSession<N> {
|
||||
}
|
||||
|
||||
/// Returns the next request id
|
||||
fn next_id(&mut self) -> u64 {
|
||||
const fn next_id(&mut self) -> u64 {
|
||||
let id = self.next_id;
|
||||
self.next_id += 1;
|
||||
id
|
||||
|
||||
@@ -30,15 +30,15 @@ impl SessionCounter {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn inc_pending_inbound(&mut self) {
|
||||
pub(crate) const fn inc_pending_inbound(&mut self) {
|
||||
self.pending_inbound += 1;
|
||||
}
|
||||
|
||||
pub(crate) fn inc_pending_outbound(&mut self) {
|
||||
pub(crate) const fn inc_pending_outbound(&mut self) {
|
||||
self.pending_outbound += 1;
|
||||
}
|
||||
|
||||
pub(crate) fn dec_pending(&mut self, direction: &Direction) {
|
||||
pub(crate) const fn dec_pending(&mut self, direction: &Direction) {
|
||||
match direction {
|
||||
Direction::Outgoing(_) => {
|
||||
self.pending_outbound -= 1;
|
||||
@@ -49,7 +49,7 @@ impl SessionCounter {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn inc_active(&mut self, direction: &Direction) {
|
||||
pub(crate) const fn inc_active(&mut self, direction: &Direction) {
|
||||
match direction {
|
||||
Direction::Outgoing(_) => {
|
||||
self.active_outbound += 1;
|
||||
@@ -60,7 +60,7 @@ impl SessionCounter {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn dec_active(&mut self, direction: &Direction) {
|
||||
pub(crate) const fn dec_active(&mut self, direction: &Direction) {
|
||||
match direction {
|
||||
Direction::Outgoing(_) => {
|
||||
self.active_outbound -= 1;
|
||||
|
||||
@@ -168,7 +168,7 @@ impl<N: NetworkPrimitives> SessionManager<N> {
|
||||
}
|
||||
|
||||
/// Returns the next unique [`SessionId`].
|
||||
fn next_id(&mut self) -> SessionId {
|
||||
const fn next_id(&mut self) -> SessionId {
|
||||
let id = self.next_id;
|
||||
self.next_id += 1;
|
||||
SessionId(id)
|
||||
|
||||
@@ -114,12 +114,12 @@ impl<N: NetworkPrimitives> NetworkState<N> {
|
||||
}
|
||||
|
||||
/// Returns mutable access to the [`PeersManager`]
|
||||
pub(crate) fn peers_mut(&mut self) -> &mut PeersManager {
|
||||
pub(crate) const fn peers_mut(&mut self) -> &mut PeersManager {
|
||||
&mut self.peers_manager
|
||||
}
|
||||
|
||||
/// Returns mutable access to the [`Discovery`]
|
||||
pub(crate) fn discovery_mut(&mut self) -> &mut Discovery {
|
||||
pub(crate) const fn discovery_mut(&mut self) -> &mut Discovery {
|
||||
&mut self.discovery
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ impl<N: NetworkPrimitives> Swarm<N> {
|
||||
}
|
||||
|
||||
/// Mutable access to the state.
|
||||
pub(crate) fn state_mut(&mut self) -> &mut NetworkState<N> {
|
||||
pub(crate) const fn state_mut(&mut self) -> &mut NetworkState<N> {
|
||||
&mut self.state
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ impl<N: NetworkPrimitives> Swarm<N> {
|
||||
}
|
||||
|
||||
/// Mutable access to the [`SessionManager`].
|
||||
pub(crate) fn sessions_mut(&mut self) -> &mut SessionManager<N> {
|
||||
pub(crate) const fn sessions_mut(&mut self) -> &mut SessionManager<N> {
|
||||
&mut self.sessions
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ impl<N: NetworkPrimitives> Swarm<N> {
|
||||
}
|
||||
|
||||
/// Set network connection state to `ShuttingDown`
|
||||
pub(crate) fn on_shutdown_requested(&mut self) {
|
||||
pub(crate) const fn on_shutdown_requested(&mut self) {
|
||||
self.state_mut().peers_mut().on_shutdown();
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ impl<N: NetworkPrimitives> Swarm<N> {
|
||||
}
|
||||
|
||||
/// Set network connection state to `Hibernate` or `Active`
|
||||
pub(crate) fn on_network_state_change(&mut self, network_state: NetworkConnectionState) {
|
||||
pub(crate) const fn on_network_state_change(&mut self, network_state: NetworkConnectionState) {
|
||||
self.state_mut().peers_mut().on_network_state_change(network_state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns mutable access to the network.
|
||||
pub fn network_mut(&mut self) -> &mut NetworkManager<EthNetworkPrimitives> {
|
||||
pub const fn network_mut(&mut self) -> &mut NetworkManager<EthNetworkPrimitives> {
|
||||
&mut self.network
|
||||
}
|
||||
|
||||
|
||||
@@ -1037,7 +1037,7 @@ pub struct TxFetchMetadata {
|
||||
|
||||
impl TxFetchMetadata {
|
||||
/// Returns a mutable reference to the fallback peers cache for this transaction hash.
|
||||
pub fn fallback_peers_mut(&mut self) -> &mut LruCache<PeerId> {
|
||||
pub const fn fallback_peers_mut(&mut self) -> &mut LruCache<PeerId> {
|
||||
&mut self.fallback_peers
|
||||
}
|
||||
|
||||
|
||||
@@ -1863,12 +1863,12 @@ impl<N: NetworkPrimitives> PeerMetadata<N> {
|
||||
}
|
||||
|
||||
/// Returns a reference to the peer's request sender channel.
|
||||
pub fn request_tx(&self) -> &PeerRequestSender<PeerRequest<N>> {
|
||||
pub const fn request_tx(&self) -> &PeerRequestSender<PeerRequest<N>> {
|
||||
&self.request_tx
|
||||
}
|
||||
|
||||
/// Return a
|
||||
pub fn seen_transactions_mut(&mut self) -> &mut LruCache<TxHash> {
|
||||
pub const fn seen_transactions_mut(&mut self) -> &mut LruCache<TxHash> {
|
||||
&mut self.seen_transactions
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ impl TestFullBlockClient {
|
||||
}
|
||||
|
||||
/// Set the soft response limit.
|
||||
pub fn set_soft_limit(&mut self, limit: usize) {
|
||||
pub const fn set_soft_limit(&mut self, limit: usize) {
|
||||
self.soft_limit = limit;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ impl<DB, ChainSpec> NodeBuilder<DB, ChainSpec> {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the node builder's config.
|
||||
pub fn config_mut(&mut self) -> &mut NodeConfig<ChainSpec> {
|
||||
pub const fn config_mut(&mut self) -> &mut NodeConfig<ChainSpec> {
|
||||
&mut self.config
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ pub struct BasicPayloadServiceBuilder<PB>(PB);
|
||||
|
||||
impl<PB> BasicPayloadServiceBuilder<PB> {
|
||||
/// Create a new [`BasicPayloadServiceBuilder`].
|
||||
pub fn new(payload_builder_builder: PB) -> Self {
|
||||
pub const fn new(payload_builder_builder: PB) -> Self {
|
||||
Self(payload_builder_builder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,12 +251,12 @@ impl<L, R> LaunchContextWith<Attached<L, R>> {
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the right value.
|
||||
pub fn left_mut(&mut self) -> &mut L {
|
||||
pub const fn left_mut(&mut self) -> &mut L {
|
||||
&mut self.attachment.left
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the right value.
|
||||
pub fn right_mut(&mut self) -> &mut R {
|
||||
pub const fn right_mut(&mut self) -> &mut R {
|
||||
&mut self.attachment.right
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,7 @@ impl<R, ChainSpec: EthChainSpec> LaunchContextWith<Attached<WithConfigs<ChainSpe
|
||||
}
|
||||
|
||||
/// Returns the attached [`NodeConfig`].
|
||||
pub fn node_config_mut(&mut self) -> &mut NodeConfig<ChainSpec> {
|
||||
pub const fn node_config_mut(&mut self) -> &mut NodeConfig<ChainSpec> {
|
||||
&mut self.left_mut().config
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ impl<R, ChainSpec: EthChainSpec> LaunchContextWith<Attached<WithConfigs<ChainSpe
|
||||
}
|
||||
|
||||
/// Returns the attached toml config [`reth_config::Config`].
|
||||
pub fn toml_config_mut(&mut self) -> &mut reth_config::Config {
|
||||
pub const fn toml_config_mut(&mut self) -> &mut reth_config::Config {
|
||||
&mut self.left_mut().toml_config
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns mutable reference to the configured `NodeAdapter`.
|
||||
pub fn node_adapter_mut(&mut self) -> &mut NodeAdapter<T, CB::Components> {
|
||||
pub const fn node_adapter_mut(&mut self) -> &mut NodeAdapter<T, CB::Components> {
|
||||
&mut self.right_mut().node_adapter
|
||||
}
|
||||
|
||||
@@ -981,12 +981,12 @@ impl<L, R> Attached<L, R> {
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the right value.
|
||||
pub fn left_mut(&mut self) -> &mut R {
|
||||
pub const fn left_mut(&mut self) -> &mut R {
|
||||
&mut self.right
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the right value.
|
||||
pub fn right_mut(&mut self) -> &mut R {
|
||||
pub const fn right_mut(&mut self) -> &mut R {
|
||||
&mut self.right
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ pub struct DebugNodeLauncher<L = EngineNodeLauncher> {
|
||||
|
||||
impl<L> DebugNodeLauncher<L> {
|
||||
/// Creates a new instance of the [`DebugNodeLauncher`].
|
||||
pub fn new(inner: L) -> Self {
|
||||
pub const fn new(inner: L) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ where
|
||||
T::Value: Into<u64>,
|
||||
{
|
||||
/// Creates a new instance with the given inner parser
|
||||
pub fn new(inner: T) -> Self {
|
||||
pub const fn new(inner: T) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ impl<C: ChainSpecParser<ChainSpec = OpChainSpec>> ImportOpCommand<C> {
|
||||
|
||||
impl<C: ChainSpecParser> ImportOpCommand<C> {
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
Some(&self.env.chain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ impl<C: ChainSpecParser<ChainSpec = OpChainSpec>> ImportReceiptsOpCommand<C> {
|
||||
|
||||
impl<C: ChainSpecParser> ImportReceiptsOpCommand<C> {
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
|
||||
Some(&self.env.chain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ impl Command {
|
||||
Ok(())
|
||||
}
|
||||
/// Returns the underlying chain being used to run this command
|
||||
pub fn chain_spec(&self) -> Option<&Arc<ChainSpec>> {
|
||||
pub const fn chain_spec(&self) -> Option<&Arc<ChainSpec>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct OpBlockAssembler<ChainSpec> {
|
||||
|
||||
impl<ChainSpec> OpBlockAssembler<ChainSpec> {
|
||||
/// Creates a new [`OpBlockAssembler`].
|
||||
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
|
||||
pub const fn new(chain_spec: Arc<ChainSpec>) -> Self {
|
||||
Self { chain_spec }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ impl OpAddOnsBuilder {
|
||||
}
|
||||
|
||||
/// Configure if transaction conditional should be enabled.
|
||||
pub fn with_enable_tx_conditional(mut self, enable_tx_conditional: bool) -> Self {
|
||||
pub const fn with_enable_tx_conditional(mut self, enable_tx_conditional: bool) -> Self {
|
||||
self.enable_tx_conditional = enable_tx_conditional;
|
||||
self
|
||||
}
|
||||
@@ -505,7 +505,7 @@ impl<T> Default for OpPoolBuilder<T> {
|
||||
|
||||
impl<T> OpPoolBuilder<T> {
|
||||
/// Sets the `enable_tx_conditional` flag on the pool builder.
|
||||
pub fn with_enable_tx_conditional(mut self, enable_tx_conditional: bool) -> Self {
|
||||
pub const fn with_enable_tx_conditional(mut self, enable_tx_conditional: bool) -> Self {
|
||||
self.enable_tx_conditional = enable_tx_conditional;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ impl<Pool, Client, Evm> OpPayloadBuilder<Pool, Client, Evm> {
|
||||
}
|
||||
|
||||
/// Configures the builder with the given [`OpBuilderConfig`].
|
||||
pub fn with_builder_config(
|
||||
pub const fn with_builder_config(
|
||||
pool: Pool,
|
||||
client: Client,
|
||||
evm_config: Evm,
|
||||
@@ -440,7 +440,7 @@ pub struct ExecutionInfo {
|
||||
|
||||
impl ExecutionInfo {
|
||||
/// Create a new instance with allocated slots.
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self { cumulative_gas_used: 0, cumulative_da_bytes_used: 0, total_fees: U256::ZERO }
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns the configured sequencer client, if any.
|
||||
fn sequencer_client(&self) -> Option<&SequencerClient> {
|
||||
const fn sequencer_client(&self) -> Option<&SequencerClient> {
|
||||
self.sequencer_client.as_ref()
|
||||
}
|
||||
|
||||
@@ -187,12 +187,12 @@ impl<Pool, Provider> OpEthExtApiInner<Pool, Provider> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn pool(&self) -> &Pool {
|
||||
const fn pool(&self) -> &Pool {
|
||||
&self.pool
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn provider(&self) -> &Provider {
|
||||
const fn provider(&self) -> &Provider {
|
||||
&self.provider
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ pub trait MaybeInteropTransaction {
|
||||
/// Helper to keep track of cross transaction interop validity
|
||||
/// Checks if provided timestamp fits into tx validation window
|
||||
#[inline]
|
||||
pub fn is_valid_interop(timeout: u64, timestamp: u64) -> bool {
|
||||
pub const fn is_valid_interop(timeout: u64, timestamp: u64) -> bool {
|
||||
timestamp < timeout
|
||||
}
|
||||
|
||||
/// Checks if transaction needs revalidation based on offset
|
||||
#[inline]
|
||||
pub fn is_stale_interop(timeout: u64, timestamp: u64, offset: u64) -> bool {
|
||||
pub const fn is_stale_interop(timeout: u64, timestamp: u64, offset: u64) -> bool {
|
||||
timestamp + offset > timeout
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ impl SupervisorClient {
|
||||
}
|
||||
|
||||
/// Configures a custom timeout
|
||||
pub fn with_timeout(mut self, timeout: Duration) -> Self {
|
||||
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
|
||||
self.timeout = timeout;
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns safely level
|
||||
pub fn safety(&self) -> SafetyLevel {
|
||||
pub const fn safety(&self) -> SafetyLevel {
|
||||
self.safety
|
||||
}
|
||||
|
||||
@@ -140,13 +140,13 @@ pub struct CheckAccessListRequest<'a> {
|
||||
|
||||
impl<'a> CheckAccessListRequest<'a> {
|
||||
/// Configures the timeout to use for the request if any.
|
||||
pub fn with_timeout(mut self, timeout: Duration) -> Self {
|
||||
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
|
||||
self.timeout = timeout;
|
||||
self
|
||||
}
|
||||
|
||||
/// Configures the [`SafetyLevel`] for this request
|
||||
pub fn with_safety(mut self, safety: SafetyLevel) -> Self {
|
||||
pub const fn with_safety(mut self, safety: SafetyLevel) -> Self {
|
||||
self.safety = safety;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ where
|
||||
{
|
||||
/// Create a new [`BetterPayloadEmitter`] with the given inner payload builder.
|
||||
/// Owns the sender half of a broadcast channel that emits the better payloads.
|
||||
pub fn new(better_payloads_tx: broadcast::Sender<Arc<PB::BuiltPayload>>, inner: PB) -> Self {
|
||||
pub const fn new(
|
||||
better_payloads_tx: broadcast::Sender<Arc<PB::BuiltPayload>>,
|
||||
inner: PB,
|
||||
) -> Self {
|
||||
Self { better_payloads_tx, inner }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub fn ensure_well_formed_fields<T: Typed2718>(
|
||||
|
||||
/// Checks that Prague fields are not present on sidecar unless Prague is active.
|
||||
#[inline]
|
||||
pub fn ensure_well_formed_sidecar_fields(
|
||||
pub const fn ensure_well_formed_sidecar_fields(
|
||||
prague_fields: Option<&PraguePayloadFields>,
|
||||
is_prague_active: bool,
|
||||
) -> Result<(), PayloadError> {
|
||||
|
||||
@@ -460,7 +460,7 @@ where
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
impl<B: Block> RecoveredBlock<B> {
|
||||
/// Returns a mutable reference to the recovered senders.
|
||||
pub fn senders_mut(&mut self) -> &mut Vec<Address> {
|
||||
pub const fn senders_mut(&mut self) -> &mut Vec<Address> {
|
||||
&mut self.senders
|
||||
}
|
||||
|
||||
@@ -493,12 +493,12 @@ impl<B: crate::test_utils::TestBlock> RecoveredBlock<B> {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the header.
|
||||
pub fn header_mut(&mut self) -> &mut B::Header {
|
||||
pub const fn header_mut(&mut self) -> &mut B::Header {
|
||||
self.block.header_mut()
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the header.
|
||||
pub fn block_mut(&mut self) -> &mut B::Body {
|
||||
pub const fn block_mut(&mut self) -> &mut B::Body {
|
||||
self.block.body_mut()
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ where
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
impl<B: crate::test_utils::TestBlock> SealedBlock<B> {
|
||||
/// Returns a mutable reference to the header.
|
||||
pub fn header_mut(&mut self) -> &mut B::Header {
|
||||
pub const fn header_mut(&mut self) -> &mut B::Header {
|
||||
self.header.header_mut()
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ impl<B: crate::test_utils::TestBlock> SealedBlock<B> {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the header.
|
||||
pub fn body_mut(&mut self) -> &mut B::Body {
|
||||
pub const fn body_mut(&mut self) -> &mut B::Body {
|
||||
&mut self.body
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ impl<H: crate::test_utils::TestHeader> SealedHeader<H> {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the header.
|
||||
pub fn header_mut(&mut self) -> &mut H {
|
||||
pub const fn header_mut(&mut self) -> &mut H {
|
||||
&mut self.header
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ impl PruneTimeLimit {
|
||||
impl PruneLimiter {
|
||||
/// Sets the limit on the number of deleted entries (rows in the database).
|
||||
/// If the limit was already set, it will be overwritten.
|
||||
pub fn set_deleted_entries_limit(mut self, limit: usize) -> Self {
|
||||
pub const fn set_deleted_entries_limit(mut self, limit: usize) -> Self {
|
||||
if let Some(deleted_entries_limit) = self.deleted_entries_limit.as_mut() {
|
||||
deleted_entries_limit.limit = limit;
|
||||
} else {
|
||||
@@ -83,14 +83,14 @@ impl PruneLimiter {
|
||||
}
|
||||
|
||||
/// Increments the number of deleted entries by the given number.
|
||||
pub fn increment_deleted_entries_count_by(&mut self, entries: usize) {
|
||||
pub const fn increment_deleted_entries_count_by(&mut self, entries: usize) {
|
||||
if let Some(limit) = self.deleted_entries_limit.as_mut() {
|
||||
limit.deleted += entries;
|
||||
}
|
||||
}
|
||||
|
||||
/// Increments the number of deleted entries by one.
|
||||
pub fn increment_deleted_entries_count(&mut self) {
|
||||
pub const fn increment_deleted_entries_count(&mut self) {
|
||||
self.increment_deleted_entries_count_by(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ impl<'a, Provider> HeaderTablesIter<'a, Provider>
|
||||
where
|
||||
Provider: DBProvider<Tx: DbTxMut>,
|
||||
{
|
||||
fn new(
|
||||
const fn new(
|
||||
provider: &'a Provider,
|
||||
limiter: &'a mut PruneLimiter,
|
||||
headers_walker: Walker<'a, Provider, tables::Headers>,
|
||||
|
||||
@@ -77,7 +77,7 @@ impl<P> RessProtocolConnection<P> {
|
||||
}
|
||||
|
||||
/// Returns the next request id
|
||||
fn next_id(&mut self) -> u64 {
|
||||
const fn next_id(&mut self) -> u64 {
|
||||
let id = self.next_id;
|
||||
self.next_id += 1;
|
||||
id
|
||||
|
||||
@@ -32,62 +32,62 @@ impl<'a> arbitrary::Arbitrary<'a> for RessProtocolMessage {
|
||||
|
||||
impl RessProtocolMessage {
|
||||
/// Returns the capability for the `ress` protocol.
|
||||
pub fn capability() -> Capability {
|
||||
pub const fn capability() -> Capability {
|
||||
Capability::new_static("ress", 1)
|
||||
}
|
||||
|
||||
/// Returns the protocol for the `ress` protocol.
|
||||
pub fn protocol() -> Protocol {
|
||||
pub const fn protocol() -> Protocol {
|
||||
Protocol::new(Self::capability(), 9)
|
||||
}
|
||||
|
||||
/// Create node type message.
|
||||
pub fn node_type(node_type: NodeType) -> Self {
|
||||
pub const fn node_type(node_type: NodeType) -> Self {
|
||||
RessMessage::NodeType(node_type).into_protocol_message()
|
||||
}
|
||||
|
||||
/// Headers request.
|
||||
pub fn get_headers(request_id: u64, request: GetHeaders) -> Self {
|
||||
pub const fn get_headers(request_id: u64, request: GetHeaders) -> Self {
|
||||
RessMessage::GetHeaders(RequestPair { request_id, message: request })
|
||||
.into_protocol_message()
|
||||
}
|
||||
|
||||
/// Headers response.
|
||||
pub fn headers(request_id: u64, headers: Vec<Header>) -> Self {
|
||||
pub const fn headers(request_id: u64, headers: Vec<Header>) -> Self {
|
||||
RessMessage::Headers(RequestPair { request_id, message: headers }).into_protocol_message()
|
||||
}
|
||||
|
||||
/// Block bodies request.
|
||||
pub fn get_block_bodies(request_id: u64, block_hashes: Vec<B256>) -> Self {
|
||||
pub const fn get_block_bodies(request_id: u64, block_hashes: Vec<B256>) -> Self {
|
||||
RessMessage::GetBlockBodies(RequestPair { request_id, message: block_hashes })
|
||||
.into_protocol_message()
|
||||
}
|
||||
|
||||
/// Block bodies response.
|
||||
pub fn block_bodies(request_id: u64, bodies: Vec<BlockBody>) -> Self {
|
||||
pub const fn block_bodies(request_id: u64, bodies: Vec<BlockBody>) -> Self {
|
||||
RessMessage::BlockBodies(RequestPair { request_id, message: bodies })
|
||||
.into_protocol_message()
|
||||
}
|
||||
|
||||
/// Bytecode request.
|
||||
pub fn get_bytecode(request_id: u64, code_hash: B256) -> Self {
|
||||
pub const fn get_bytecode(request_id: u64, code_hash: B256) -> Self {
|
||||
RessMessage::GetBytecode(RequestPair { request_id, message: code_hash })
|
||||
.into_protocol_message()
|
||||
}
|
||||
|
||||
/// Bytecode response.
|
||||
pub fn bytecode(request_id: u64, bytecode: Bytes) -> Self {
|
||||
pub const fn bytecode(request_id: u64, bytecode: Bytes) -> Self {
|
||||
RessMessage::Bytecode(RequestPair { request_id, message: bytecode }).into_protocol_message()
|
||||
}
|
||||
|
||||
/// Execution witness request.
|
||||
pub fn get_witness(request_id: u64, block_hash: BlockHash) -> Self {
|
||||
pub const fn get_witness(request_id: u64, block_hash: BlockHash) -> Self {
|
||||
RessMessage::GetWitness(RequestPair { request_id, message: block_hash })
|
||||
.into_protocol_message()
|
||||
}
|
||||
|
||||
/// Execution witness response.
|
||||
pub fn witness(request_id: u64, witness: Vec<Bytes>) -> Self {
|
||||
pub const fn witness(request_id: u64, witness: Vec<Bytes>) -> Self {
|
||||
RessMessage::Witness(RequestPair { request_id, message: witness }).into_protocol_message()
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ pub enum RessMessage {
|
||||
|
||||
impl RessMessage {
|
||||
/// Return [`RessMessageID`] that corresponds to the given message.
|
||||
pub fn message_id(&self) -> RessMessageID {
|
||||
pub const fn message_id(&self) -> RessMessageID {
|
||||
match self {
|
||||
Self::NodeType(_) => RessMessageID::NodeType,
|
||||
Self::GetHeaders(_) => RessMessageID::GetHeaders,
|
||||
@@ -231,7 +231,7 @@ impl RessMessage {
|
||||
}
|
||||
|
||||
/// Convert message into [`RessProtocolMessage`].
|
||||
pub fn into_protocol_message(self) -> RessProtocolMessage {
|
||||
pub const fn into_protocol_message(self) -> RessProtocolMessage {
|
||||
let message_type = self.message_id();
|
||||
RessProtocolMessage { message_type, message: self }
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ pub struct MockRessProtocolProvider {
|
||||
|
||||
impl MockRessProtocolProvider {
|
||||
/// Configure witness response delay.
|
||||
pub fn with_witness_delay(mut self, delay: Duration) -> Self {
|
||||
pub const fn with_witness_delay(mut self, delay: Duration) -> Self {
|
||||
self.witness_delay = Some(delay);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ impl Decodable for NodeType {
|
||||
|
||||
impl NodeType {
|
||||
/// Return `true` if node type is stateful.
|
||||
pub fn is_stateful(&self) -> bool {
|
||||
pub const fn is_stateful(&self) -> bool {
|
||||
matches!(self, Self::Stateful)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ impl NodeType {
|
||||
/// ----------|-----------|----------|
|
||||
/// stateless | + | + |
|
||||
/// stateful | + | - |
|
||||
pub fn is_valid_connection(&self, other: &Self) -> bool {
|
||||
pub const fn is_valid_connection(&self, other: &Self) -> bool {
|
||||
!self.is_stateful() || !other.is_stateful()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ pub struct CachedReads {
|
||||
|
||||
impl CachedReads {
|
||||
/// Gets a [`DatabaseRef`] that will cache reads from the given database.
|
||||
pub fn as_db<DB>(&mut self, db: DB) -> CachedReadsDBRef<'_, DB> {
|
||||
pub const fn as_db<DB>(&mut self, db: DB) -> CachedReadsDBRef<'_, DB> {
|
||||
self.as_db_mut(db).into_db()
|
||||
}
|
||||
|
||||
/// Gets a mutable [`Database`] that will cache reads from the underlying database.
|
||||
pub fn as_db_mut<DB>(&mut self, db: DB) -> CachedReadsDbMut<'_, DB> {
|
||||
pub const fn as_db_mut<DB>(&mut self, db: DB) -> CachedReadsDbMut<'_, DB> {
|
||||
CachedReadsDbMut { cached: self, db }
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ impl IpcClientBuilder {
|
||||
}
|
||||
|
||||
/// Set request timeout (default is 60 seconds).
|
||||
pub fn request_timeout(mut self, timeout: Duration) -> Self {
|
||||
pub const fn request_timeout(mut self, timeout: Duration) -> Self {
|
||||
self.request_timeout = timeout;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ impl AuthRpcModule {
|
||||
}
|
||||
|
||||
/// Get a reference to the inner `RpcModule`.
|
||||
pub fn module_mut(&mut self) -> &mut RpcModule<()> {
|
||||
pub const fn module_mut(&mut self) -> &mut RpcModule<()> {
|
||||
&mut self.inner
|
||||
}
|
||||
|
||||
|
||||
@@ -693,7 +693,7 @@ impl RpcModuleConfig {
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the eth namespace config
|
||||
pub fn eth_mut(&mut self) -> &mut EthConfig {
|
||||
pub const fn eth_mut(&mut self) -> &mut EthConfig {
|
||||
&mut self.eth
|
||||
}
|
||||
}
|
||||
@@ -732,7 +732,7 @@ impl RpcModuleConfigBuilder {
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the eth namespace config, if any
|
||||
pub fn eth_mut(&mut self) -> &mut Option<EthConfig> {
|
||||
pub const fn eth_mut(&mut self) -> &mut Option<EthConfig> {
|
||||
&mut self.eth
|
||||
}
|
||||
|
||||
@@ -1732,22 +1732,22 @@ impl TransportRpcModuleConfig {
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the
|
||||
pub fn http_mut(&mut self) -> &mut Option<RpcModuleSelection> {
|
||||
pub const fn http_mut(&mut self) -> &mut Option<RpcModuleSelection> {
|
||||
&mut self.http
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the
|
||||
pub fn ws_mut(&mut self) -> &mut Option<RpcModuleSelection> {
|
||||
pub const fn ws_mut(&mut self) -> &mut Option<RpcModuleSelection> {
|
||||
&mut self.ws
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the
|
||||
pub fn ipc_mut(&mut self) -> &mut Option<RpcModuleSelection> {
|
||||
pub const fn ipc_mut(&mut self) -> &mut Option<RpcModuleSelection> {
|
||||
&mut self.ipc
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the
|
||||
pub fn config_mut(&mut self) -> &mut Option<RpcModuleConfig> {
|
||||
pub const fn config_mut(&mut self) -> &mut Option<RpcModuleConfig> {
|
||||
&mut self.config
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,10 @@ where
|
||||
|
||||
/// Sets `eth_cache` config for the cache that will be used if no [`EthStateCache`] is
|
||||
/// configured.
|
||||
pub fn eth_state_cache_config(mut self, eth_state_cache_config: EthStateCacheConfig) -> Self {
|
||||
pub const fn eth_state_cache_config(
|
||||
mut self,
|
||||
eth_state_cache_config: EthStateCacheConfig,
|
||||
) -> Self {
|
||||
self.eth_state_cache_config = eth_state_cache_config;
|
||||
self
|
||||
}
|
||||
@@ -96,7 +99,7 @@ where
|
||||
|
||||
/// Sets `gas_oracle` config for the gas oracle that will be used if no [`GasPriceOracle`] is
|
||||
/// configured.
|
||||
pub fn gas_oracle_config(mut self, gas_oracle_config: GasPriceOracleConfig) -> Self {
|
||||
pub const fn gas_oracle_config(mut self, gas_oracle_config: GasPriceOracleConfig) -> Self {
|
||||
self.gas_oracle_config = gas_oracle_config;
|
||||
self
|
||||
}
|
||||
@@ -132,7 +135,7 @@ where
|
||||
}
|
||||
|
||||
/// Sets the fee history cache.
|
||||
pub fn fee_history_cache_config(
|
||||
pub const fn fee_history_cache_config(
|
||||
mut self,
|
||||
fee_history_cache_config: FeeHistoryCacheConfig,
|
||||
) -> Self {
|
||||
|
||||
@@ -298,7 +298,7 @@ pub enum StageUnitCheckpoint {
|
||||
impl StageUnitCheckpoint {
|
||||
/// Sets the block range. Returns old block range, or `None` if checkpoint doesn't use block
|
||||
/// range.
|
||||
pub fn set_block_range(&mut self, from: u64, to: u64) -> Option<CheckpointBlockRange> {
|
||||
pub const fn set_block_range(&mut self, from: u64, to: u64) -> Option<CheckpointBlockRange> {
|
||||
match self {
|
||||
Self::Account(AccountHashingCheckpoint { ref mut block_range, .. }) |
|
||||
Self::Storage(StorageHashingCheckpoint { ref mut block_range, .. }) |
|
||||
|
||||
@@ -53,7 +53,7 @@ impl HighestStaticFiles {
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to a static file segment
|
||||
pub fn as_mut(&mut self, segment: StaticFileSegment) -> &mut Option<BlockNumber> {
|
||||
pub const fn as_mut(&mut self, segment: StaticFileSegment) -> &mut Option<BlockNumber> {
|
||||
match segment {
|
||||
StaticFileSegment::Headers => &mut self.headers,
|
||||
StaticFileSegment::Transactions => &mut self.transactions,
|
||||
|
||||
@@ -237,7 +237,7 @@ impl SegmentHeader {
|
||||
}
|
||||
|
||||
/// Increments block end range depending on segment
|
||||
pub fn increment_block(&mut self) -> BlockNumber {
|
||||
pub const fn increment_block(&mut self) -> BlockNumber {
|
||||
if let Some(block_range) = &mut self.block_range {
|
||||
block_range.end += 1;
|
||||
block_range.end
|
||||
@@ -251,7 +251,7 @@ impl SegmentHeader {
|
||||
}
|
||||
|
||||
/// Increments tx end range depending on segment
|
||||
pub fn increment_tx(&mut self) {
|
||||
pub const fn increment_tx(&mut self) {
|
||||
if self.segment.is_tx_based() {
|
||||
if let Some(tx_range) = &mut self.tx_range {
|
||||
tx_range.end += 1;
|
||||
@@ -262,7 +262,7 @@ impl SegmentHeader {
|
||||
}
|
||||
|
||||
/// Removes `num` elements from end of tx or block range.
|
||||
pub fn prune(&mut self, num: u64) {
|
||||
pub const fn prune(&mut self, num: u64) {
|
||||
if self.segment.is_block_based() {
|
||||
if let Some(range) = &mut self.block_range {
|
||||
if num > range.end - range.start {
|
||||
@@ -281,7 +281,7 @@ impl SegmentHeader {
|
||||
}
|
||||
|
||||
/// Sets a new `block_range`.
|
||||
pub fn set_block_range(&mut self, block_start: BlockNumber, block_end: BlockNumber) {
|
||||
pub const fn set_block_range(&mut self, block_start: BlockNumber, block_end: BlockNumber) {
|
||||
if let Some(block_range) = &mut self.block_range {
|
||||
block_range.start = block_start;
|
||||
block_range.end = block_end;
|
||||
@@ -291,7 +291,7 @@ impl SegmentHeader {
|
||||
}
|
||||
|
||||
/// Sets a new `tx_range`.
|
||||
pub fn set_tx_range(&mut self, tx_start: TxNumber, tx_end: TxNumber) {
|
||||
pub const fn set_tx_range(&mut self, tx_start: TxNumber, tx_end: TxNumber) {
|
||||
if let Some(tx_range) = &mut self.tx_range {
|
||||
tx_range.start = tx_start;
|
||||
tx_range.end = tx_end;
|
||||
|
||||
@@ -157,7 +157,7 @@ impl<T: Table, CURSOR: DbCursorRO<T>> Iterator for Walker<'_, T, CURSOR> {
|
||||
|
||||
impl<'cursor, T: Table, CURSOR: DbCursorRO<T>> Walker<'cursor, T, CURSOR> {
|
||||
/// construct Walker
|
||||
pub fn new(cursor: &'cursor mut CURSOR, start: IterPairResult<T>) -> Self {
|
||||
pub const fn new(cursor: &'cursor mut CURSOR, start: IterPairResult<T>) -> Self {
|
||||
Self { cursor, start }
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ where
|
||||
|
||||
impl<'cursor, T: Table, CURSOR: DbCursorRO<T>> ReverseWalker<'cursor, T, CURSOR> {
|
||||
/// construct `ReverseWalker`
|
||||
pub fn new(cursor: &'cursor mut CURSOR, start: IterPairResult<T>) -> Self {
|
||||
pub const fn new(cursor: &'cursor mut CURSOR, start: IterPairResult<T>) -> Self {
|
||||
Self { cursor, start }
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ impl ListFilter {
|
||||
}
|
||||
|
||||
/// Updates the page with new `skip` and `len` values.
|
||||
pub fn update_page(&mut self, skip: usize, len: usize) {
|
||||
pub const fn update_page(&mut self, skip: usize, len: usize) {
|
||||
self.skip = skip;
|
||||
self.len = len;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ pub mod test_utils {
|
||||
}
|
||||
|
||||
/// Returns the reference to inner db.
|
||||
pub fn db(&self) -> &DB {
|
||||
pub const fn db(&self) -> &DB {
|
||||
self.db.as_ref().unwrap()
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ impl Stat {
|
||||
}
|
||||
|
||||
/// Returns a mut pointer to `ffi::MDB_stat`.
|
||||
pub(crate) fn mdb_stat(&mut self) -> *mut ffi::MDBX_stat {
|
||||
pub(crate) const fn mdb_stat(&mut self) -> *mut ffi::MDBX_stat {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
@@ -757,7 +757,7 @@ impl EnvironmentBuilder {
|
||||
}
|
||||
|
||||
/// Configures how this environment will be opened.
|
||||
pub fn set_kind(&mut self, kind: EnvironmentKind) -> &mut Self {
|
||||
pub const fn set_kind(&mut self, kind: EnvironmentKind) -> &mut Self {
|
||||
self.kind = kind;
|
||||
self
|
||||
}
|
||||
@@ -765,12 +765,12 @@ impl EnvironmentBuilder {
|
||||
/// Opens the environment with mdbx WRITEMAP
|
||||
///
|
||||
/// See also [`EnvironmentKind`]
|
||||
pub fn write_map(&mut self) -> &mut Self {
|
||||
pub const fn write_map(&mut self) -> &mut Self {
|
||||
self.set_kind(EnvironmentKind::WriteMap)
|
||||
}
|
||||
|
||||
/// Sets the provided options in the environment.
|
||||
pub fn set_flags(&mut self, flags: EnvironmentFlags) -> &mut Self {
|
||||
pub const fn set_flags(&mut self, flags: EnvironmentFlags) -> &mut Self {
|
||||
self.flags = flags;
|
||||
self
|
||||
}
|
||||
@@ -780,7 +780,7 @@ impl EnvironmentBuilder {
|
||||
/// This defines the number of slots in the lock table that is used to track readers in the
|
||||
/// the environment. The default is 126. Starting a read-only transaction normally ties a lock
|
||||
/// table slot to the [Transaction] object until it or the [Environment] object is destroyed.
|
||||
pub fn set_max_readers(&mut self, max_readers: u64) -> &mut Self {
|
||||
pub const fn set_max_readers(&mut self, max_readers: u64) -> &mut Self {
|
||||
self.max_readers = Some(max_readers);
|
||||
self
|
||||
}
|
||||
@@ -794,14 +794,14 @@ impl EnvironmentBuilder {
|
||||
/// Currently a moderate number of slots are cheap but a huge number gets
|
||||
/// expensive: 7-120 words per transaction, and every [`Transaction::open_db()`]
|
||||
/// does a linear search of the opened slots.
|
||||
pub fn set_max_dbs(&mut self, v: usize) -> &mut Self {
|
||||
pub const fn set_max_dbs(&mut self, v: usize) -> &mut Self {
|
||||
self.max_dbs = Some(v as u64);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the interprocess/shared threshold to force flush the data buffers to disk, if
|
||||
/// [`SyncMode::SafeNoSync`] is used.
|
||||
pub fn set_sync_bytes(&mut self, v: usize) -> &mut Self {
|
||||
pub const fn set_sync_bytes(&mut self, v: usize) -> &mut Self {
|
||||
self.sync_bytes = Some(v as u64);
|
||||
self
|
||||
}
|
||||
@@ -815,22 +815,22 @@ impl EnvironmentBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_rp_augment_limit(&mut self, v: u64) -> &mut Self {
|
||||
pub const fn set_rp_augment_limit(&mut self, v: u64) -> &mut Self {
|
||||
self.rp_augment_limit = Some(v);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_loose_limit(&mut self, v: u64) -> &mut Self {
|
||||
pub const fn set_loose_limit(&mut self, v: u64) -> &mut Self {
|
||||
self.loose_limit = Some(v);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_dp_reserve_limit(&mut self, v: u64) -> &mut Self {
|
||||
pub const fn set_dp_reserve_limit(&mut self, v: u64) -> &mut Self {
|
||||
self.dp_reserve_limit = Some(v);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_txn_dp_limit(&mut self, v: u64) -> &mut Self {
|
||||
pub const fn set_txn_dp_limit(&mut self, v: u64) -> &mut Self {
|
||||
self.txn_dp_limit = Some(v);
|
||||
self
|
||||
}
|
||||
@@ -863,7 +863,7 @@ impl EnvironmentBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_log_level(&mut self, log_level: ffi::MDBX_log_level_t) -> &mut Self {
|
||||
pub const fn set_log_level(&mut self, log_level: ffi::MDBX_log_level_t) -> &mut Self {
|
||||
self.log_level = Some(log_level);
|
||||
self
|
||||
}
|
||||
@@ -903,7 +903,7 @@ pub(crate) mod read_transactions {
|
||||
|
||||
impl EnvironmentBuilder {
|
||||
/// Set the maximum time a read-only transaction can be open.
|
||||
pub fn set_max_read_transaction_duration(
|
||||
pub const fn set_max_read_transaction_duration(
|
||||
&mut self,
|
||||
max_read_transaction_duration: MaxReadTransactionDuration,
|
||||
) -> &mut Self {
|
||||
|
||||
@@ -653,7 +653,7 @@ impl CommitLatency {
|
||||
}
|
||||
|
||||
/// Returns a mut pointer to `ffi::MDBX_commit_latency`.
|
||||
pub(crate) fn mdb_commit_latency(&mut self) -> *mut ffi::MDBX_commit_latency {
|
||||
pub(crate) const fn mdb_commit_latency(&mut self) -> *mut ffi::MDBX_commit_latency {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,14 +168,14 @@ impl<H: NippyJarHeader> NippyJarChecker<H> {
|
||||
/// Returns a mutable reference to offsets file.
|
||||
///
|
||||
/// **Panics** if it does not exist.
|
||||
fn offsets_file(&mut self) -> &mut BufWriter<File> {
|
||||
const fn offsets_file(&mut self) -> &mut BufWriter<File> {
|
||||
self.offsets_file.as_mut().expect("should exist")
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to data file.
|
||||
///
|
||||
/// **Panics** if it does not exist.
|
||||
fn data_file(&mut self) -> &mut BufWriter<File> {
|
||||
const fn data_file(&mut self) -> &mut BufWriter<File> {
|
||||
self.data_file.as_mut().expect("should exist")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ impl<'a, H: NippyJarHeader> NippyJarCursor<'a, H> {
|
||||
}
|
||||
|
||||
/// Resets cursor to the beginning.
|
||||
pub fn reset(&mut self) {
|
||||
pub const fn reset(&mut self) {
|
||||
self.row = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ impl<H: NippyJarHeader> NippyJar<H> {
|
||||
}
|
||||
|
||||
/// Gets a mutable reference to the compressor.
|
||||
pub fn compressor_mut(&mut self) -> Option<&mut Compressors> {
|
||||
pub const fn compressor_mut(&mut self) -> Option<&mut Compressors> {
|
||||
self.compressor.as_mut()
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
|
||||
///
|
||||
/// Since there's no way of knowing if `H` has been actually changed, this sets `self.dirty` to
|
||||
/// true.
|
||||
pub fn user_header_mut(&mut self) -> &mut H {
|
||||
pub const fn user_header_mut(&mut self) -> &mut H {
|
||||
self.dirty = true;
|
||||
&mut self.jar.user_header
|
||||
}
|
||||
@@ -109,7 +109,7 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
|
||||
}
|
||||
|
||||
/// Sets writer as dirty.
|
||||
pub fn set_dirty(&mut self) {
|
||||
pub const fn set_dirty(&mut self) {
|
||||
self.dirty = true
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
|
||||
|
||||
/// Returns a mutable reference to the offsets vector.
|
||||
#[cfg(test)]
|
||||
pub fn offsets_mut(&mut self) -> &mut Vec<u64> {
|
||||
pub const fn offsets_mut(&mut self) -> &mut Vec<u64> {
|
||||
&mut self.offsets
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
|
||||
|
||||
/// Returns a mutable reference to the buffered writer for the data file.
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
pub fn data_file(&mut self) -> &mut BufWriter<File> {
|
||||
pub const fn data_file(&mut self) -> &mut BufWriter<File> {
|
||||
&mut self.data_file
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ impl ReadOnlyConfig {
|
||||
|
||||
/// Whether the static file directory should be watches for changes, see also
|
||||
/// [`StaticFileProvider::read_only`]
|
||||
pub fn set_watch_static_files(&mut self, watch_static_files: bool) {
|
||||
pub const fn set_watch_static_files(&mut self, watch_static_files: bool) {
|
||||
self.watch_static_files = watch_static_files;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ impl ReadOnlyConfig {
|
||||
///
|
||||
/// This is only recommended if this is used without a running node instance that modifies
|
||||
/// static files.
|
||||
pub fn no_watch(mut self) -> Self {
|
||||
pub const fn no_watch(mut self) -> Self {
|
||||
self.set_watch_static_files(false);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ impl<TX: DbTx + 'static, N: NodeTypesForProvider> DatabaseProvider<TX, N> {
|
||||
}
|
||||
|
||||
/// Pass `DbTx` or `DbTxMut` mutable reference.
|
||||
pub fn tx_mut(&mut self) -> &mut TX {
|
||||
pub const fn tx_mut(&mut self) -> &mut TX {
|
||||
&mut self.tx
|
||||
}
|
||||
|
||||
|
||||
@@ -847,19 +847,19 @@ impl<N: NodePrimitives> StaticFileProviderRW<N> {
|
||||
}
|
||||
|
||||
/// Helper function to access a mutable reference to [`SegmentHeader`].
|
||||
pub fn user_header_mut(&mut self) -> &mut SegmentHeader {
|
||||
pub const fn user_header_mut(&mut self) -> &mut SegmentHeader {
|
||||
self.writer.user_header_mut()
|
||||
}
|
||||
|
||||
/// Helper function to override block range for testing.
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
pub fn set_block_range(&mut self, block_range: std::ops::RangeInclusive<BlockNumber>) {
|
||||
pub const fn set_block_range(&mut self, block_range: std::ops::RangeInclusive<BlockNumber>) {
|
||||
self.writer.user_header_mut().set_block_range(*block_range.start(), *block_range.end())
|
||||
}
|
||||
|
||||
/// Helper function to override block range for testing.
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
pub fn inner(&mut self) -> &mut NippyJarWriter<SegmentHeader> {
|
||||
pub const fn inner(&mut self) -> &mut NippyJarWriter<SegmentHeader> {
|
||||
&mut self.writer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ impl<'a, ProviderDB, ProviderSF> UnifiedStorageWriter<'a, ProviderDB, ProviderSF
|
||||
///
|
||||
/// # Panics
|
||||
/// If the static file instance is not set.
|
||||
fn static_file(&self) -> &ProviderSF {
|
||||
const fn static_file(&self) -> &ProviderSF {
|
||||
self.static_file.as_ref().expect("should exist")
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user