Add missing_const_for_fn clippy lint (#8498)

This commit is contained in:
Thomas Coratger
2024-05-30 11:50:03 +02:00
committed by GitHub
parent 99068198db
commit 3d3f52b2a4
255 changed files with 834 additions and 804 deletions

View File

@@ -588,31 +588,31 @@ impl Default for Builder<Identity, Identity> {
impl<HttpMiddleware, RpcMiddleware> Builder<HttpMiddleware, RpcMiddleware> {
/// Set the maximum size of a request body in bytes. Default is 10 MiB.
pub fn max_request_body_size(mut self, size: u32) -> Self {
pub const fn max_request_body_size(mut self, size: u32) -> Self {
self.settings.max_request_body_size = size;
self
}
/// Set the maximum size of a response body in bytes. Default is 10 MiB.
pub fn max_response_body_size(mut self, size: u32) -> Self {
pub const fn max_response_body_size(mut self, size: u32) -> Self {
self.settings.max_response_body_size = size;
self
}
/// Set the maximum size of a log
pub fn max_log_length(mut self, size: u32) -> Self {
pub const fn max_log_length(mut self, size: u32) -> Self {
self.settings.max_log_length = size;
self
}
/// Set the maximum number of connections allowed. Default is 100.
pub fn max_connections(mut self, max: u32) -> Self {
pub const fn max_connections(mut self, max: u32) -> Self {
self.settings.max_connections = max;
self
}
/// Set the maximum number of connections allowed. Default is 1024.
pub fn max_subscriptions_per_connection(mut self, max: u32) -> Self {
pub const fn max_subscriptions_per_connection(mut self, max: u32) -> Self {
self.settings.max_subscriptions_per_connection = max;
self
}
@@ -634,7 +634,7 @@ impl<HttpMiddleware, RpcMiddleware> Builder<HttpMiddleware, RpcMiddleware> {
/// # Panics
///
/// Panics if the buffer capacity is 0.
pub fn set_message_buffer_capacity(mut self, c: u32) -> Self {
pub const fn set_message_buffer_capacity(mut self, c: u32) -> Self {
self.settings.message_buffer_capacity = c;
self
}

View File

@@ -36,7 +36,7 @@ pub(crate) enum RpcServiceCfg {
impl RpcService {
/// Create a new service.
pub(crate) fn new(
pub(crate) const fn new(
methods: Methods,
max_response_body_size: usize,
conn_id: usize,

View File

@@ -61,13 +61,13 @@ impl StreamCodec {
}
/// New custom stream codec
pub fn new(incoming_separator: Separator, outgoing_separator: Separator) -> Self {
pub const fn new(incoming_separator: Separator, outgoing_separator: Separator) -> Self {
Self { incoming_separator, outgoing_separator }
}
}
#[inline]
fn is_whitespace(byte: u8) -> bool {
const fn is_whitespace(byte: u8) -> bool {
matches!(byte, 0x0D | 0x0A | 0x20 | 0x09)
}

View File

@@ -170,12 +170,12 @@ pub struct AuthServerConfig {
impl AuthServerConfig {
/// Convenience function to create a new `AuthServerConfig`.
pub fn builder(secret: JwtSecret) -> AuthServerConfigBuilder {
pub const fn builder(secret: JwtSecret) -> AuthServerConfigBuilder {
AuthServerConfigBuilder::new(secret)
}
/// Returns the address the server will listen on.
pub fn address(&self) -> SocketAddr {
pub const fn address(&self) -> SocketAddr {
self.socket_addr
}
@@ -231,7 +231,7 @@ pub struct AuthServerConfigBuilder {
impl AuthServerConfigBuilder {
/// Create a new `AuthServerConfigBuilder` with the given `secret`.
pub fn new(secret: JwtSecret) -> Self {
pub const fn new(secret: JwtSecret) -> Self {
Self {
socket_addr: None,
secret,
@@ -242,19 +242,19 @@ impl AuthServerConfigBuilder {
}
/// Set the socket address for the server.
pub fn socket_addr(mut self, socket_addr: SocketAddr) -> Self {
pub const fn socket_addr(mut self, socket_addr: SocketAddr) -> Self {
self.socket_addr = Some(socket_addr);
self
}
/// Set the socket address for the server.
pub fn maybe_socket_addr(mut self, socket_addr: Option<SocketAddr>) -> Self {
pub const fn maybe_socket_addr(mut self, socket_addr: Option<SocketAddr>) -> Self {
self.socket_addr = socket_addr;
self
}
/// Set the secret for the server.
pub fn secret(mut self, secret: JwtSecret) -> Self {
pub const fn secret(mut self, secret: JwtSecret) -> Self {
self.secret = secret;
self
}
@@ -379,7 +379,7 @@ pub struct AuthServerHandle {
impl AuthServerHandle {
/// Returns the [`SocketAddr`] of the http server if started.
pub fn local_addr(&self) -> SocketAddr {
pub const fn local_addr(&self) -> SocketAddr {
self.local_addr
}

View File

@@ -17,7 +17,7 @@ pub enum ServerKind {
impl ServerKind {
/// Returns the appropriate flags for each variant.
pub fn flags(&self) -> &'static str {
pub const fn flags(&self) -> &'static str {
match self {
Self::Http(_) => "--http.port",
Self::WS(_) => "--ws.port",

View File

@@ -81,37 +81,37 @@ impl Default for EthConfig {
impl EthConfig {
/// Configures the caching layer settings
pub fn state_cache(mut self, cache: EthStateCacheConfig) -> Self {
pub const fn state_cache(mut self, cache: EthStateCacheConfig) -> Self {
self.cache = cache;
self
}
/// Configures the gas price oracle settings
pub fn gpo_config(mut self, gas_oracle_config: GasPriceOracleConfig) -> Self {
pub const fn gpo_config(mut self, gas_oracle_config: GasPriceOracleConfig) -> Self {
self.gas_oracle = gas_oracle_config;
self
}
/// Configures the maximum number of tracing requests
pub fn max_tracing_requests(mut self, max_requests: usize) -> Self {
pub const fn max_tracing_requests(mut self, max_requests: usize) -> Self {
self.max_tracing_requests = max_requests;
self
}
/// Configures the maximum block length to scan per `eth_getLogs` request
pub fn max_blocks_per_filter(mut self, max_blocks: u64) -> Self {
pub const fn max_blocks_per_filter(mut self, max_blocks: u64) -> Self {
self.max_blocks_per_filter = max_blocks;
self
}
/// Configures the maximum number of logs per response
pub fn max_logs_per_response(mut self, max_logs: usize) -> Self {
pub const fn max_logs_per_response(mut self, max_logs: usize) -> Self {
self.max_logs_per_response = max_logs;
self
}
/// Configures the maximum gas limit for `eth_call` and call tracing RPC methods
pub fn rpc_gas_cap(mut self, rpc_gas_cap: u64) -> Self {
pub const fn rpc_gas_cap(mut self, rpc_gas_cap: u64) -> Self {
self.rpc_gas_cap = rpc_gas_cap;
self
}

View File

@@ -293,7 +293,7 @@ impl<Provider, Pool, Network, Tasks, Events, EvmConfig>
RpcModuleBuilder<Provider, Pool, Network, Tasks, Events, EvmConfig>
{
/// Create a new instance of the builder
pub fn new(
pub const fn new(
provider: Provider,
pool: Pool,
network: Network,
@@ -571,7 +571,7 @@ impl RpcModuleConfig {
RpcModuleConfigBuilder::default()
}
/// Returns a new RPC module config given the eth namespace config
pub fn new(eth: EthConfig) -> Self {
pub const fn new(eth: EthConfig) -> Self {
Self { eth }
}
}
@@ -586,7 +586,7 @@ pub struct RpcModuleConfigBuilder {
impl RpcModuleConfigBuilder {
/// Configures a custom eth namespace config
pub fn eth(mut self, eth: EthConfig) -> Self {
pub const fn eth(mut self, eth: EthConfig) -> Self {
self.eth = Some(eth);
self
}
@@ -952,22 +952,22 @@ impl<Provider, Pool, Network, Tasks, Events, EvmConfig>
}
/// Returns a reference to the pool
pub fn pool(&self) -> &Pool {
pub const fn pool(&self) -> &Pool {
&self.pool
}
/// Returns a reference to the events type
pub fn events(&self) -> &Events {
pub const fn events(&self) -> &Events {
&self.events
}
/// Returns a reference to the tasks type
pub fn tasks(&self) -> &Tasks {
pub const fn tasks(&self) -> &Tasks {
&self.executor
}
/// Returns a reference to the provider
pub fn provider(&self) -> &Provider {
pub const fn provider(&self) -> &Provider {
&self.provider
}
@@ -1506,7 +1506,7 @@ impl RpcServerConfig {
/// Configures the [SocketAddr] of the http server
///
/// Default is [Ipv4Addr::LOCALHOST] and [DEFAULT_HTTP_RPC_PORT]
pub fn with_http_address(mut self, addr: SocketAddr) -> Self {
pub const fn with_http_address(mut self, addr: SocketAddr) -> Self {
self.http_addr = Some(addr);
self
}
@@ -1514,7 +1514,7 @@ impl RpcServerConfig {
/// Configures the [SocketAddr] of the ws server
///
/// Default is [Ipv4Addr::LOCALHOST] and [DEFAULT_WS_RPC_PORT]
pub fn with_ws_address(mut self, addr: SocketAddr) -> Self {
pub const fn with_ws_address(mut self, addr: SocketAddr) -> Self {
self.ws_addr = Some(addr);
self
}
@@ -1557,7 +1557,7 @@ impl RpcServerConfig {
}
/// Configures the JWT secret for authentication.
pub fn with_jwt_secret(mut self, secret: Option<JwtSecret>) -> Self {
pub const fn with_jwt_secret(mut self, secret: Option<JwtSecret>) -> Self {
self.jwt_secret = secret;
self
}
@@ -1565,19 +1565,19 @@ impl RpcServerConfig {
/// Returns true if any server is configured.
///
/// If no server is configured, no server will be be launched on [RpcServerConfig::start].
pub fn has_server(&self) -> bool {
pub const fn has_server(&self) -> bool {
self.http_server_config.is_some() ||
self.ws_server_config.is_some() ||
self.ipc_server_config.is_some()
}
/// Returns the [SocketAddr] of the http server
pub fn http_address(&self) -> Option<SocketAddr> {
pub const fn http_address(&self) -> Option<SocketAddr> {
self.http_addr
}
/// Returns the [SocketAddr] of the ws server
pub fn ws_address(&self) -> Option<SocketAddr> {
pub const fn ws_address(&self) -> Option<SocketAddr> {
self.ws_addr
}
@@ -1814,28 +1814,28 @@ impl TransportRpcModuleConfig {
}
/// Sets a custom [RpcModuleConfig] for the configured modules.
pub fn with_config(mut self, config: RpcModuleConfig) -> Self {
pub const fn with_config(mut self, config: RpcModuleConfig) -> Self {
self.config = Some(config);
self
}
/// Returns true if no transports are configured
pub fn is_empty(&self) -> bool {
pub const fn is_empty(&self) -> bool {
self.http.is_none() && self.ws.is_none() && self.ipc.is_none()
}
/// Returns the [RpcModuleSelection] for the http transport
pub fn http(&self) -> Option<&RpcModuleSelection> {
pub const fn http(&self) -> Option<&RpcModuleSelection> {
self.http.as_ref()
}
/// Returns the [RpcModuleSelection] for the ws transport
pub fn ws(&self) -> Option<&RpcModuleSelection> {
pub const fn ws(&self) -> Option<&RpcModuleSelection> {
self.ws.as_ref()
}
/// Returns the [RpcModuleSelection] for the ipc transport
pub fn ipc(&self) -> Option<&RpcModuleSelection> {
pub const fn ipc(&self) -> Option<&RpcModuleSelection> {
self.ipc.as_ref()
}
@@ -1871,7 +1871,7 @@ pub struct TransportRpcModules<Context = ()> {
impl TransportRpcModules {
/// Returns the [TransportRpcModuleConfig] used to configure this instance.
pub fn module_config(&self) -> &TransportRpcModuleConfig {
pub const fn module_config(&self) -> &TransportRpcModuleConfig {
&self.config
}
@@ -2025,16 +2025,16 @@ impl RpcServer {
}
/// Returns the [`SocketAddr`] of the http server if started.
pub fn http_local_addr(&self) -> Option<SocketAddr> {
pub const fn http_local_addr(&self) -> Option<SocketAddr> {
self.ws_http.http_local_addr
}
/// Return the JwtSecret of the server
pub fn jwt(&self) -> Option<JwtSecret> {
pub const fn jwt(&self) -> Option<JwtSecret> {
self.ws_http.jwt_secret
}
/// Returns the [`SocketAddr`] of the ws server if started.
pub fn ws_local_addr(&self) -> Option<SocketAddr> {
pub const fn ws_local_addr(&self) -> Option<SocketAddr> {
self.ws_http.ws_local_addr
}
@@ -2123,12 +2123,12 @@ impl RpcServerHandle {
})
}
/// Returns the [`SocketAddr`] of the http server if started.
pub fn http_local_addr(&self) -> Option<SocketAddr> {
pub const fn http_local_addr(&self) -> Option<SocketAddr> {
self.http_local_addr
}
/// Returns the [`SocketAddr`] of the ws server if started.
pub fn ws_local_addr(&self) -> Option<SocketAddr> {
pub const fn ws_local_addr(&self) -> Option<SocketAddr> {
self.ws_local_addr
}

View File

@@ -86,7 +86,7 @@ impl RawRpcParamsBuilder {
}
/// Sets the ID for the JSON-RPC request.
pub fn set_id(mut self, id: i32) -> Self {
pub const fn set_id(mut self, id: i32) -> Self {
self.id = id;
self
}

View File

@@ -4,4 +4,4 @@ mod serde;
mod startup;
pub mod utils;
fn main() {}
const fn main() {}

View File

@@ -19,7 +19,7 @@ use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use tokio::sync::mpsc::unbounded_channel;
/// Localhost with port 0 so a free port is used.
pub fn test_address() -> SocketAddr {
pub const fn test_address() -> SocketAddr {
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0))
}

View File

@@ -1,3 +1,3 @@
mod payload;
fn main() {}
const fn main() {}

View File

@@ -15,7 +15,7 @@ pub struct AuthClientLayer {
impl AuthClientLayer {
/// Create a new AuthClientLayer with the given `secret`.
pub fn new(secret: JwtSecret) -> Self {
pub const fn new(secret: JwtSecret) -> Self {
Self { secret }
}
}
@@ -36,7 +36,7 @@ pub struct AuthClientService<S> {
}
impl<S> AuthClientService<S> {
fn new(secret: JwtSecret, inner: S) -> Self {
const fn new(secret: JwtSecret, inner: S) -> Self {
Self { secret, inner }
}
}

View File

@@ -47,7 +47,7 @@ pub struct AuthLayer<V> {
impl<V> AuthLayer<V> {
/// Creates an instance of [`AuthLayer`].
/// `validator` is a generic trait able to validate requests (see [`AuthValidator`]).
pub fn new(validator: V) -> Self {
pub const fn new(validator: V) -> Self {
Self { validator }
}
}
@@ -115,11 +115,11 @@ impl<F, B> ResponseFuture<F, B>
where
B: Body,
{
fn future(future: F) -> Self {
const fn future(future: F) -> Self {
Self { kind: Kind::Future { future } }
}
fn invalid_auth(err_res: Response<B>) -> Self {
const fn invalid_auth(err_res: Response<B>) -> Self {
Self { kind: Kind::Error { response: Some(err_res) } }
}
}

View File

@@ -16,7 +16,7 @@ impl JwtAuthValidator {
/// Creates a new instance of [`JwtAuthValidator`].
/// Validation logics are implemented by the `secret`
/// argument (see [`JwtSecret`]).
pub fn new(secret: JwtSecret) -> Self {
pub const fn new(secret: JwtSecret) -> Self {
Self { secret }
}
}

View File

@@ -438,7 +438,7 @@ where
///
/// * `client1` - The first RPC client.
/// * `client2` - The second RPC client.
pub fn new(client1: C1, client2: C2) -> Self {
pub const fn new(client1: C1, client2: C2) -> Self {
Self { client1, client2 }
}
@@ -519,7 +519,7 @@ mod tests {
use reth_primitives::BlockNumberOrTag;
use reth_rpc_types::trace::filter::TraceFilterMode;
fn assert_is_stream<St: Stream>(_: &St) {}
const fn assert_is_stream<St: Stream>(_: &St) {}
#[tokio::test]
async fn can_create_block_stream() {

View File

@@ -1,3 +1,3 @@
mod trace;
fn main() {}
const fn main() {}

View File

@@ -47,13 +47,13 @@ pub struct Inclusion {
impl Inclusion {
/// Creates a new inclusion with the given min block..
pub fn at_block(block: u64) -> Self {
pub const fn at_block(block: u64) -> Self {
Self { block, max_block: None }
}
/// Returns the block number of the first block the bundle is valid for.
#[inline]
pub fn block_number(&self) -> u64 {
pub const fn block_number(&self) -> u64 {
self.block
}
@@ -155,76 +155,76 @@ pub struct PrivacyHint {
impl PrivacyHint {
/// Sets the flag indicating inclusion of calldata and returns the modified PrivacyHint
/// instance.
pub fn with_calldata(mut self) -> Self {
pub const fn with_calldata(mut self) -> Self {
self.calldata = true;
self
}
/// Sets the flag indicating inclusion of contract address and returns the modified PrivacyHint
/// instance.
pub fn with_contract_address(mut self) -> Self {
pub const fn with_contract_address(mut self) -> Self {
self.contract_address = true;
self
}
/// Sets the flag indicating inclusion of logs and returns the modified PrivacyHint instance.
pub fn with_logs(mut self) -> Self {
pub const fn with_logs(mut self) -> Self {
self.logs = true;
self
}
/// Sets the flag indicating inclusion of function selector and returns the modified PrivacyHint
/// instance.
pub fn with_function_selector(mut self) -> Self {
pub const fn with_function_selector(mut self) -> Self {
self.function_selector = true;
self
}
/// Sets the flag indicating inclusion of hash and returns the modified PrivacyHint instance.
pub fn with_hash(mut self) -> Self {
pub const fn with_hash(mut self) -> Self {
self.hash = true;
self
}
/// Sets the flag indicating inclusion of transaction hash and returns the modified PrivacyHint
/// instance.
pub fn with_tx_hash(mut self) -> Self {
pub const fn with_tx_hash(mut self) -> Self {
self.tx_hash = true;
self
}
/// Checks if calldata inclusion flag is set.
pub fn has_calldata(&self) -> bool {
pub const fn has_calldata(&self) -> bool {
self.calldata
}
/// Checks if contract address inclusion flag is set.
pub fn has_contract_address(&self) -> bool {
pub const fn has_contract_address(&self) -> bool {
self.contract_address
}
/// Checks if logs inclusion flag is set.
pub fn has_logs(&self) -> bool {
pub const fn has_logs(&self) -> bool {
self.logs
}
/// Checks if function selector inclusion flag is set.
pub fn has_function_selector(&self) -> bool {
pub const fn has_function_selector(&self) -> bool {
self.function_selector
}
/// Checks if hash inclusion flag is set.
pub fn has_hash(&self) -> bool {
pub const fn has_hash(&self) -> bool {
self.hash
}
/// Checks if transaction hash inclusion flag is set.
pub fn has_tx_hash(&self) -> bool {
pub const fn has_tx_hash(&self) -> bool {
self.tx_hash
}
/// Calculates the number of hints set within the PrivacyHint instance.
fn num_hints(&self) -> usize {
const fn num_hints(&self) -> usize {
let mut num_hints = 0;
if self.calldata {
num_hints += 1;
@@ -456,7 +456,7 @@ pub struct PrivateTransactionPreferences {
impl PrivateTransactionPreferences {
/// Returns true if the preferences are empty.
pub fn is_empty(&self) -> bool {
pub const fn is_empty(&self) -> bool {
self.validity.is_none() && self.privacy.is_none()
}
}

View File

@@ -11,7 +11,7 @@ pub struct RpcModules {
impl RpcModules {
/// Create a new instance of RPCModules
pub fn new(module_map: HashMap<String, String>) -> Self {
pub const fn new(module_map: HashMap<String, String>) -> Self {
Self { module_map }
}

View File

@@ -24,7 +24,7 @@ pub struct EngineEthApi<Eth, EthFilter> {
impl<Eth, EthFilter> EngineEthApi<Eth, EthFilter> {
/// Create a new `EngineEthApi` instance.
pub fn new(eth: Eth, eth_filter: EthFilter) -> Self {
pub const fn new(eth: Eth, eth_filter: EthFilter) -> Self {
Self { eth, eth_filter }
}
}

View File

@@ -21,7 +21,7 @@ pub(crate) struct OptimismTxMeta {
impl OptimismTxMeta {
/// Creates a new [OptimismTxMeta].
pub(crate) fn new(
pub(crate) const fn new(
l1_block_info: Option<L1BlockInfo>,
l1_fee: Option<u128>,
l1_data_gas: Option<u128>,

View File

@@ -335,7 +335,7 @@ pub(crate) enum PendingBlockEnvOrigin {
impl PendingBlockEnvOrigin {
/// Returns true if the origin is the actual pending block as received from the CL.
pub(crate) fn is_actual_pending(&self) -> bool {
pub(crate) const fn is_actual_pending(&self) -> bool {
matches!(self, Self::ActualPending(_))
}

View File

@@ -367,7 +367,7 @@ pub enum OptimismInvalidTransactionError {
impl RpcInvalidTransactionError {
/// Returns the rpc error code for this error.
fn error_code(&self) -> i32 {
const fn error_code(&self) -> i32 {
match self {
Self::InvalidChainId | Self::GasTooLow | Self::GasTooHigh => {
EthRpcErrorCode::InvalidInput.code()
@@ -380,7 +380,7 @@ impl RpcInvalidTransactionError {
/// Converts the halt error
///
/// Takes the configured gas limit of the transaction which is attached to the error
pub(crate) fn halt(reason: HaltReason, gas_limit: u64) -> Self {
pub(crate) const fn halt(reason: HaltReason, gas_limit: u64) -> Self {
match reason {
HaltReason::OutOfGas(err) => Self::out_of_gas(err, gas_limit),
HaltReason::NonceOverflow => Self::NonceMaxValue,
@@ -389,7 +389,7 @@ impl RpcInvalidTransactionError {
}
/// Converts the out of gas error
pub(crate) fn out_of_gas(reason: OutOfGasError, gas_limit: u64) -> Self {
pub(crate) const fn out_of_gas(reason: OutOfGasError, gas_limit: u64) -> Self {
match reason {
OutOfGasError::Basic => Self::BasicOutOfGas(gas_limit),
OutOfGasError::Memory => Self::MemoryOutOfGas(gas_limit),
@@ -508,7 +508,7 @@ impl RevertError {
}
}
fn error_code(&self) -> i32 {
const fn error_code(&self) -> i32 {
EthRpcErrorCode::ExecutionError.code()
}
}

View File

@@ -533,20 +533,20 @@ pub struct EthFilterConfig {
impl EthFilterConfig {
/// Sets the maximum number of blocks that a filter can scan for logs.
pub fn max_blocks_per_filter(mut self, num: u64) -> Self {
pub const fn max_blocks_per_filter(mut self, num: u64) -> Self {
self.max_blocks_per_filter = Some(num);
self
}
/// Sets the maximum number of logs that can be returned in a single response in `eth_getLogs`
/// calls.
pub fn max_logs_per_response(mut self, num: usize) -> Self {
pub const fn max_logs_per_response(mut self, num: usize) -> Self {
self.max_logs_per_response = Some(num);
self
}
/// Sets how long a filter remains valid after the last poll before it will be removed.
pub fn stale_filter_ttl(mut self, duration: Duration) -> Self {
pub const fn stale_filter_ttl(mut self, duration: Duration) -> Self {
self.stale_filter_ttl = duration;
self
}

View File

@@ -119,7 +119,7 @@ where
}
/// Returns the configuration of the gas price oracle.
pub fn config(&self) -> &GasPriceOracleConfig {
pub const fn config(&self) -> &GasPriceOracleConfig {
&self.oracle_config
}

View File

@@ -42,17 +42,17 @@ pub struct EvmOverrides {
impl EvmOverrides {
/// Creates a new instance with the given overrides
pub fn new(state: Option<StateOverride>, block: Option<Box<BlockOverrides>>) -> Self {
pub const fn new(state: Option<StateOverride>, block: Option<Box<BlockOverrides>>) -> Self {
Self { state, block }
}
/// Creates a new instance with the given state overrides.
pub fn state(state: Option<StateOverride>) -> Self {
pub const fn state(state: Option<StateOverride>) -> Self {
Self { state, block: None }
}
/// Returns `true` if the overrides contain state overrides.
pub fn has_state(&self) -> bool {
pub const fn has_state(&self) -> bool {
self.state.is_some()
}
}

View File

@@ -19,7 +19,7 @@ pub struct NetApi<Net, Eth> {
impl<Net, Eth> NetApi<Net, Eth> {
/// Returns a new instance with the given network and eth interface implementations
pub fn new(network: Net, eth: Eth) -> Self {
pub const fn new(network: Net, eth: Eth) -> Self {
Self { network, eth }
}
}

View File

@@ -26,7 +26,7 @@ pub struct OtterscanApi<Eth> {
impl<Eth> OtterscanApi<Eth> {
/// Creates a new instance of `Otterscan`.
pub fn new(eth: Eth) -> Self {
pub const fn new(eth: Eth) -> Self {
Self { eth }
}
}

View File

@@ -154,7 +154,7 @@ mod tests {
use super::*;
use reth_errors::{RethError, RethResult};
fn assert_rpc_result<T, E, TRR: ToRpcResult<T, E>>() {}
const fn assert_rpc_result<T, E, TRR: ToRpcResult<T, E>>() {}
#[test]
fn can_convert_rpc() {

View File

@@ -21,7 +21,7 @@ pub struct TxPoolApi<Pool> {
impl<Pool> TxPoolApi<Pool> {
/// Creates a new instance of `TxpoolApi`.
pub fn new(pool: Pool) -> Self {
pub const fn new(pool: Pool) -> Self {
Self { pool }
}
}

View File

@@ -15,7 +15,7 @@ pub struct Web3Api<N> {
impl<N> Web3Api<N> {
/// Creates a new instance of `Web3Api`.
pub fn new(network: N) -> Self {
pub const fn new(network: N) -> Self {
Self { network }
}
}