mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make clippy happy (#8068)
This commit is contained in:
@ -1216,7 +1216,7 @@ where
|
||||
///
|
||||
/// The block, `revert_until`, is __non-inclusive__, i.e. `revert_until` stays in the database.
|
||||
fn revert_canonical_from_database(
|
||||
&mut self,
|
||||
&self,
|
||||
revert_until: BlockNumber,
|
||||
) -> Result<Option<Chain>, CanonicalError> {
|
||||
// read data that is needed for new sidechain
|
||||
@ -1239,7 +1239,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn update_reorg_metrics(&mut self, reorg_depth: f64) {
|
||||
fn update_reorg_metrics(&self, reorg_depth: f64) {
|
||||
self.metrics.reorgs.increment(1);
|
||||
self.metrics.latest_reorg_depth.set(reorg_depth);
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ impl StorageInner {
|
||||
///
|
||||
/// This returns the poststate from execution and post-block changes, as well as the gas used.
|
||||
pub(crate) fn execute<EvmConfig>(
|
||||
&mut self,
|
||||
&self,
|
||||
block: &BlockWithSenders,
|
||||
executor: &mut EVMProcessor<'_, EvmConfig>,
|
||||
) -> Result<(BundleStateWithReceipts, u64), BlockExecutionError>
|
||||
|
||||
@ -124,7 +124,7 @@ impl EngineHooksController {
|
||||
}
|
||||
|
||||
fn poll_next_hook_inner(
|
||||
&mut self,
|
||||
&self,
|
||||
cx: &mut Context<'_>,
|
||||
hook: &mut Box<dyn EngineHook>,
|
||||
args: EngineHookContext,
|
||||
|
||||
@ -446,7 +446,7 @@ where
|
||||
///
|
||||
/// Returns `true` if the head needs to be updated.
|
||||
fn on_head_already_canonical(
|
||||
&mut self,
|
||||
&self,
|
||||
header: &SealedHeader,
|
||||
attrs: &mut Option<EngineT::PayloadAttributes>,
|
||||
) -> bool {
|
||||
@ -804,7 +804,7 @@ where
|
||||
/// This also updates the safe and finalized blocks in the [CanonChainTracker], if they are
|
||||
/// consistent with the head block.
|
||||
fn ensure_consistent_forkchoice_state(
|
||||
&mut self,
|
||||
&self,
|
||||
state: ForkchoiceState,
|
||||
) -> ProviderResult<Option<OnForkChoiceUpdated>> {
|
||||
// Ensure that the finalized block, if not zero, is known and in the canonical chain
|
||||
|
||||
@ -258,7 +258,7 @@ impl ExExManager {
|
||||
|
||||
/// Updates the current buffer capacity and notifies all `is_ready` watchers of the manager's
|
||||
/// readiness to receive notifications.
|
||||
fn update_capacity(&mut self) {
|
||||
fn update_capacity(&self) {
|
||||
let capacity = self.max_capacity.saturating_sub(self.buffer.len());
|
||||
self.current_capacity.store(capacity, Ordering::Relaxed);
|
||||
self.metrics.current_capacity.set(capacity as f64);
|
||||
|
||||
@ -173,7 +173,7 @@ impl<T> MeteredSender<T> {
|
||||
|
||||
/// Calls the underlying [Sender](mpsc::Sender)'s `send`, incrementing the appropriate
|
||||
/// metrics depending on the result.
|
||||
pub async fn send(&mut self, value: T) -> Result<(), SendError<T>> {
|
||||
pub async fn send(&self, value: T) -> Result<(), SendError<T>> {
|
||||
match self.sender.send(value).await {
|
||||
Ok(()) => {
|
||||
self.metrics.messages_sent.increment(1);
|
||||
|
||||
@ -992,7 +992,7 @@ impl Discv4Service {
|
||||
}
|
||||
|
||||
/// Encodes the packet, sends it and returns the hash.
|
||||
pub(crate) fn send_packet(&mut self, msg: Message, to: SocketAddr) -> B256 {
|
||||
pub(crate) fn send_packet(&self, msg: Message, to: SocketAddr) -> B256 {
|
||||
let (payload, hash) = msg.encode(&self.secret_key);
|
||||
trace!(target: "discv4", r#type=?msg.msg_type(), ?to, ?hash, "sending packet");
|
||||
let _ = self.egress.try_send((payload, to)).map_err(|err| {
|
||||
@ -1277,7 +1277,7 @@ impl Discv4Service {
|
||||
|
||||
/// Handler for incoming `EnrRequest` message
|
||||
fn on_enr_request(
|
||||
&mut self,
|
||||
&self,
|
||||
msg: EnrRequest,
|
||||
remote_addr: SocketAddr,
|
||||
id: PeerId,
|
||||
|
||||
@ -114,7 +114,7 @@ impl MockDiscovery {
|
||||
}
|
||||
|
||||
/// Encodes the packet, sends it and returns the hash.
|
||||
fn send_packet(&mut self, msg: Message, to: SocketAddr) -> B256 {
|
||||
fn send_packet(&self, msg: Message, to: SocketAddr) -> B256 {
|
||||
let (payload, hash) = msg.encode(&self.secret_key);
|
||||
let _ = self.egress.try_send((payload, to));
|
||||
hash
|
||||
|
||||
@ -220,7 +220,7 @@ impl Discv5 {
|
||||
}
|
||||
|
||||
/// Process an event from the underlying [`discv5::Discv5`] node.
|
||||
pub fn on_discv5_update(&mut self, update: discv5::Event) -> Option<DiscoveredPeer> {
|
||||
pub fn on_discv5_update(&self, update: discv5::Event) -> Option<DiscoveredPeer> {
|
||||
match update {
|
||||
discv5::Event::SocketUpdated(_) | discv5::Event::TalkRequest(_) |
|
||||
// `Discovered` not unique discovered peers
|
||||
@ -254,7 +254,7 @@ impl Discv5 {
|
||||
|
||||
/// Processes a discovered peer. Returns `true` if peer is added to
|
||||
pub fn on_discovered_peer(
|
||||
&mut self,
|
||||
&self,
|
||||
enr: &discv5::Enr,
|
||||
socket: SocketAddr,
|
||||
) -> Option<DiscoveredPeer> {
|
||||
@ -724,7 +724,7 @@ mod tests {
|
||||
let remote_key = CombinedKey::generate_secp256k1();
|
||||
let remote_enr = Enr::builder().tcp4(REMOTE_RLPX_PORT).build(&remote_key).unwrap();
|
||||
|
||||
let mut discv5 = discv5_noop();
|
||||
let discv5 = discv5_noop();
|
||||
|
||||
// test
|
||||
let filtered_peer = discv5.on_discovered_peer(&remote_enr, remote_socket);
|
||||
|
||||
@ -67,13 +67,13 @@ pub struct DnsDiscoveryHandle {
|
||||
|
||||
impl DnsDiscoveryHandle {
|
||||
/// Starts syncing the given link to a tree.
|
||||
pub fn sync_tree(&mut self, link: &str) -> Result<(), ParseDnsEntryError> {
|
||||
pub fn sync_tree(&self, link: &str) -> Result<(), ParseDnsEntryError> {
|
||||
self.sync_tree_with_link(link.parse()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Starts syncing the given link to a tree.
|
||||
pub fn sync_tree_with_link(&mut self, link: LinkEntry) {
|
||||
pub fn sync_tree_with_link(&self, link: LinkEntry) {
|
||||
let _ = self.to_service.send(DnsDiscoveryCommand::SyncTree(link));
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ where
|
||||
Provider: HeaderProvider + Unpin + 'static,
|
||||
{
|
||||
/// Returns the next contiguous request.
|
||||
fn next_headers_request(&mut self) -> DownloadResult<Option<Vec<SealedHeader>>> {
|
||||
fn next_headers_request(&self) -> DownloadResult<Option<Vec<SealedHeader>>> {
|
||||
let start_at = match self.in_progress_queue.last_requested_block_number {
|
||||
Some(num) => num + 1,
|
||||
None => *self.download_range.start(),
|
||||
|
||||
@ -224,7 +224,7 @@ impl FileClient {
|
||||
}
|
||||
|
||||
/// Returns an iterator over headers in the client.
|
||||
pub fn headers_iter(&mut self) -> impl Iterator<Item = &Header> {
|
||||
pub fn headers_iter(&self) -> impl Iterator<Item = &Header> {
|
||||
self.headers.values()
|
||||
}
|
||||
|
||||
|
||||
@ -536,7 +536,7 @@ where
|
||||
/// Handles the error of a bad response
|
||||
///
|
||||
/// This will re-submit the request.
|
||||
fn on_headers_error(&mut self, err: Box<HeadersResponseError>) {
|
||||
fn on_headers_error(&self, err: Box<HeadersResponseError>) {
|
||||
let HeadersResponseError { request, peer_id, error } = *err;
|
||||
|
||||
self.penalize_peer(peer_id, &error);
|
||||
@ -581,7 +581,7 @@ where
|
||||
}
|
||||
|
||||
/// Starts a request future
|
||||
fn submit_request(&mut self, request: HeadersRequest, priority: Priority) {
|
||||
fn submit_request(&self, request: HeadersRequest, priority: Priority) {
|
||||
trace!(target: "downloaders::headers", ?request, "Submitting headers request");
|
||||
self.in_progress_queue.push(self.request_fut(request, priority));
|
||||
self.metrics.in_flight_requests.increment(1.);
|
||||
|
||||
@ -239,7 +239,7 @@ impl<St> MultiplexInner<St> {
|
||||
}
|
||||
|
||||
/// Delegates a message to the matching protocol.
|
||||
fn delegate_message(&mut self, cap: &SharedCapability, msg: BytesMut) -> bool {
|
||||
fn delegate_message(&self, cap: &SharedCapability, msg: BytesMut) -> bool {
|
||||
for proto in &self.protocols {
|
||||
if proto.shared_cap == *cap {
|
||||
proto.send_raw(msg);
|
||||
|
||||
@ -171,7 +171,7 @@ impl<S> MuxDemuxStream<S> {
|
||||
|
||||
/// Checks if all clones of this shared stream have been dropped, if true then returns //
|
||||
/// function to drop the stream.
|
||||
fn can_drop(&mut self) -> bool {
|
||||
fn can_drop(&self) -> bool {
|
||||
for tx in self.demux.values() {
|
||||
if !tx.is_closed() {
|
||||
return false
|
||||
|
||||
@ -46,6 +46,7 @@ macro_rules! poll_nested_stream_with_budget {
|
||||
loop {
|
||||
match $poll_stream {
|
||||
Poll::Ready(Some(item)) => {
|
||||
#[allow(unused_mut)]
|
||||
let mut f = $on_ready_some;
|
||||
f(item);
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ where
|
||||
}
|
||||
|
||||
fn on_headers_request(
|
||||
&mut self,
|
||||
&self,
|
||||
_peer_id: PeerId,
|
||||
request: GetBlockHeaders,
|
||||
response: oneshot::Sender<RequestResult<BlockHeaders>>,
|
||||
@ -150,7 +150,7 @@ where
|
||||
}
|
||||
|
||||
fn on_bodies_request(
|
||||
&mut self,
|
||||
&self,
|
||||
_peer_id: PeerId,
|
||||
request: GetBlockBodies,
|
||||
response: oneshot::Sender<RequestResult<BlockBodies>>,
|
||||
@ -187,7 +187,7 @@ where
|
||||
}
|
||||
|
||||
fn on_receipts_request(
|
||||
&mut self,
|
||||
&self,
|
||||
_peer_id: PeerId,
|
||||
request: GetReceipts,
|
||||
response: oneshot::Sender<RequestResult<Receipts>>,
|
||||
|
||||
@ -130,7 +130,7 @@ impl StateFetcher {
|
||||
/// Returns the _next_ idle peer that's ready to accept a request,
|
||||
/// prioritizing those with the lowest timeout/latency and those that recently responded with
|
||||
/// adequate data.
|
||||
fn next_best_peer(&mut self) -> Option<PeerId> {
|
||||
fn next_best_peer(&self) -> Option<PeerId> {
|
||||
let mut idle = self.peers.iter().filter(|(_, peer)| peer.state.is_idle());
|
||||
|
||||
let mut best_peer = idle.next()?;
|
||||
|
||||
@ -403,7 +403,7 @@ where
|
||||
}
|
||||
|
||||
/// Handle an incoming request from the peer
|
||||
fn on_eth_request(&mut self, peer_id: PeerId, req: PeerRequest) {
|
||||
fn on_eth_request(&self, peer_id: PeerId, req: PeerRequest) {
|
||||
match req {
|
||||
PeerRequest::GetBlockHeaders { request, response } => {
|
||||
self.delegate_eth_request(IncomingEthRequest::GetBlockHeaders {
|
||||
|
||||
@ -234,7 +234,7 @@ where
|
||||
}
|
||||
|
||||
/// Invoked when a new [`ForkId`] is activated.
|
||||
pub(crate) fn update_fork_id(&mut self, fork_id: ForkId) {
|
||||
pub(crate) fn update_fork_id(&self, fork_id: ForkId) {
|
||||
self.discovery.update_fork_id(fork_id)
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ impl TransactionFetcher {
|
||||
///
|
||||
/// Returns left over hashes.
|
||||
pub fn pack_request(
|
||||
&mut self,
|
||||
&self,
|
||||
hashes_to_request: &mut RequestTxHashes,
|
||||
hashes_from_announcement: ValidAnnouncementData,
|
||||
) -> RequestTxHashes {
|
||||
@ -260,7 +260,7 @@ impl TransactionFetcher {
|
||||
/// response. If no, it's added to surplus hashes. If yes, it's added to hashes to the request
|
||||
/// and expected response size is accumulated.
|
||||
pub fn pack_request_eth68(
|
||||
&mut self,
|
||||
&self,
|
||||
hashes_to_request: &mut RequestTxHashes,
|
||||
hashes_from_announcement: impl HandleMempoolData
|
||||
+ IntoIterator<Item = (TxHash, Option<(u8, usize)>)>,
|
||||
@ -328,7 +328,7 @@ impl TransactionFetcher {
|
||||
///
|
||||
/// Returns left over hashes.
|
||||
pub fn pack_request_eth66(
|
||||
&mut self,
|
||||
&self,
|
||||
hashes_to_request: &mut RequestTxHashes,
|
||||
hashes_from_announcement: ValidAnnouncementData,
|
||||
) -> RequestTxHashes {
|
||||
|
||||
@ -232,7 +232,7 @@ impl<DB> NodeState<DB> {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_network_event(&mut self, _: NetworkEvent) {
|
||||
fn handle_network_event(&self, _: NetworkEvent) {
|
||||
// NOTE(onbjerg): This used to log established/disconnecting sessions, but this is already
|
||||
// logged in the networking component. I kept this stub in case we want to catch other
|
||||
// networking events later on.
|
||||
|
||||
@ -1041,12 +1041,12 @@ where
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
{
|
||||
/// Instantiates AdminApi
|
||||
pub fn admin_api(&mut self) -> AdminApi<Network> {
|
||||
pub fn admin_api(&self) -> AdminApi<Network> {
|
||||
AdminApi::new(self.network.clone(), self.provider.chain_spec())
|
||||
}
|
||||
|
||||
/// Instantiates Web3Api
|
||||
pub fn web3_api(&mut self) -> Web3Api<Network> {
|
||||
pub fn web3_api(&self) -> Web3Api<Network> {
|
||||
Web3Api::new(self.network.clone())
|
||||
}
|
||||
|
||||
@ -1443,7 +1443,7 @@ where
|
||||
}
|
||||
|
||||
/// Instantiates RethApi
|
||||
pub fn reth_api(&mut self) -> RethApi<Provider> {
|
||||
pub fn reth_api(&self) -> RethApi<Provider> {
|
||||
RethApi::new(self.provider.clone(), Box::new(self.executor.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ impl<Provider, Pool, Network, EvmConfig> EthApi<Provider, Pool, Network, EvmConf
|
||||
|
||||
/// Generates 20 random developer accounts.
|
||||
/// Used in DEV mode.
|
||||
pub fn with_dev_accounts(&mut self) {
|
||||
pub fn with_dev_accounts(&self) {
|
||||
let mut signers = self.inner.signers.write();
|
||||
*signers = DevSigner::random_signers(20);
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ where
|
||||
///
|
||||
/// CAUTION: This method locks the static file producer Mutex, hence can block the thread if the
|
||||
/// lock is occupied.
|
||||
pub fn produce_static_files(&mut self) -> RethResult<()> {
|
||||
pub fn produce_static_files(&self) -> RethResult<()> {
|
||||
let mut static_file_producer = self.static_file_producer.lock();
|
||||
|
||||
let provider = self.provider_factory.provider()?;
|
||||
|
||||
@ -117,7 +117,7 @@ impl MerkleStage {
|
||||
|
||||
/// Saves the hashing progress
|
||||
pub fn save_execution_checkpoint<DB: Database>(
|
||||
&mut self,
|
||||
&self,
|
||||
provider: &DatabaseProviderRW<DB>,
|
||||
checkpoint: Option<MerkleCheckpoint>,
|
||||
) -> Result<(), StageError> {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
|
||||
)]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(missing_docs, clippy::needless_pass_by_ref_mut)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
pub use crate::{
|
||||
|
||||
@ -366,7 +366,7 @@ impl<H: NippyJarHeader> NippyJar<H> {
|
||||
|
||||
/// Writes all data and configuration to a file and the offset index to another.
|
||||
pub fn freeze(
|
||||
mut self,
|
||||
self,
|
||||
columns: Vec<impl IntoIterator<Item = ColumnResult<Vec<u8>>>>,
|
||||
total_rows: u64,
|
||||
) -> Result<Self, NippyJarError> {
|
||||
@ -392,7 +392,7 @@ impl<H: NippyJarHeader> NippyJar<H> {
|
||||
}
|
||||
|
||||
/// Freezes [`PerfectHashingFunction`], [`InclusionFilter`] and the offset index to file.
|
||||
fn freeze_filters(&mut self) -> Result<(), NippyJarError> {
|
||||
fn freeze_filters(&self) -> Result<(), NippyJarError> {
|
||||
debug!(target: "nippy-jar", path=?self.index_path(), "Writing offsets and offsets index to file.");
|
||||
|
||||
let mut file = File::create(self.index_path())?;
|
||||
@ -405,7 +405,7 @@ impl<H: NippyJarHeader> NippyJar<H> {
|
||||
|
||||
/// Safety checks before creating and returning a [`File`] handle to write data to.
|
||||
fn check_before_freeze(
|
||||
&mut self,
|
||||
&self,
|
||||
columns: &[impl IntoIterator<Item = ColumnResult<Vec<u8>>>],
|
||||
) -> Result<(), NippyJarError> {
|
||||
if columns.len() != self.columns {
|
||||
@ -427,7 +427,7 @@ impl<H: NippyJarHeader> NippyJar<H> {
|
||||
}
|
||||
|
||||
/// Writes all necessary configuration to file.
|
||||
fn freeze_config(&mut self) -> Result<(), NippyJarError> {
|
||||
fn freeze_config(&self) -> Result<(), NippyJarError> {
|
||||
Ok(bincode::serialize_into(File::create(self.config_path())?, &self)?)
|
||||
}
|
||||
}
|
||||
@ -1200,7 +1200,7 @@ mod tests {
|
||||
fn append_two_rows(num_columns: usize, file_path: &Path, col1: &[Vec<u8>], col2: &[Vec<u8>]) {
|
||||
// Create and add 1 row
|
||||
{
|
||||
let mut nippy = NippyJar::new_without_header(num_columns, file_path);
|
||||
let nippy = NippyJar::new_without_header(num_columns, file_path);
|
||||
nippy.freeze_config().unwrap();
|
||||
assert_eq!(nippy.max_row_size, 0);
|
||||
assert_eq!(nippy.rows, 0);
|
||||
|
||||
@ -43,7 +43,7 @@ pub struct NippyJarWriter<H: NippyJarHeader = ()> {
|
||||
|
||||
impl<H: NippyJarHeader> NippyJarWriter<H> {
|
||||
/// Creates a [`NippyJarWriter`] from [`NippyJar`].
|
||||
pub fn new(mut jar: NippyJar<H>) -> Result<Self, NippyJarError> {
|
||||
pub fn new(jar: NippyJar<H>) -> Result<Self, NippyJarError> {
|
||||
let (data_file, offsets_file, is_created) =
|
||||
Self::create_or_open_files(jar.data_path(), &jar.offsets_path())?;
|
||||
|
||||
|
||||
@ -225,7 +225,7 @@ impl StaticFileProviderRW {
|
||||
/// Verifies if the incoming block number matches the next expected block number
|
||||
/// for a static file. This ensures data continuity when adding new blocks.
|
||||
fn check_next_block_number(
|
||||
&mut self,
|
||||
&self,
|
||||
expected_block_number: u64,
|
||||
segment: StaticFileSegment,
|
||||
) -> ProviderResult<()> {
|
||||
|
||||
@ -12,14 +12,14 @@ pub struct TestCanonStateSubscriptions {
|
||||
impl TestCanonStateSubscriptions {
|
||||
/// Adds new block commit to the queue that can be consumed with
|
||||
/// [`TestCanonStateSubscriptions::subscribe_to_canonical_state`]
|
||||
pub fn add_next_commit(&mut self, new: Arc<Chain>) {
|
||||
pub fn add_next_commit(&self, new: Arc<Chain>) {
|
||||
let event = CanonStateNotification::Commit { new };
|
||||
self.canon_notif_tx.lock().as_mut().unwrap().retain(|tx| tx.send(event.clone()).is_ok())
|
||||
}
|
||||
|
||||
/// Adds reorg to the queue that can be consumed with
|
||||
/// [`TestCanonStateSubscriptions::subscribe_to_canonical_state`]
|
||||
pub fn add_next_reorg(&mut self, old: Arc<Chain>, new: Arc<Chain>) {
|
||||
pub fn add_next_reorg(&self, old: Arc<Chain>, new: Arc<Chain>) {
|
||||
let event = CanonStateNotification::Reorg { old, new };
|
||||
self.canon_notif_tx.lock().as_mut().unwrap().retain(|tx| tx.send(event.clone()).is_ok())
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
}
|
||||
|
||||
/// Update sub-pools size metrics.
|
||||
pub(crate) fn update_size_metrics(&mut self) {
|
||||
pub(crate) fn update_size_metrics(&self) {
|
||||
let stats = self.size();
|
||||
self.metrics.pending_pool_transactions.set(stats.pending as f64);
|
||||
self.metrics.pending_pool_size_bytes.set(stats.pending_size as f64);
|
||||
@ -990,7 +990,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
|
||||
}
|
||||
|
||||
/// Updates the size metrics
|
||||
pub(crate) fn update_size_metrics(&mut self) {
|
||||
pub(crate) fn update_size_metrics(&self) {
|
||||
self.metrics.all_transactions_by_hash.set(self.by_hash.len() as f64);
|
||||
self.metrics.all_transactions_by_id.set(self.txs.len() as f64);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user