From 5b5d28e4662be0866d3cbe317983e57f951bd1f5 Mon Sep 17 00:00:00 2001 From: jbesraa Date: Tue, 9 Jul 2024 11:15:52 +0300 Subject: [PATCH] Remove dead code from `downstream_mining.rs` (cherry picked from commit f91be81b129b3f2008d0168fc1599881094f40ce) Co-authored-by: jbesraa --- .../mining-proxy/src/lib/downstream_mining.rs | 53 +------------------ roles/mining-proxy/src/lib/upstream_mining.rs | 1 - 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/roles/mining-proxy/src/lib/downstream_mining.rs b/roles/mining-proxy/src/lib/downstream_mining.rs index 907b3d6b0..da8901c49 100644 --- a/roles/mining-proxy/src/lib/downstream_mining.rs +++ b/roles/mining-proxy/src/lib/downstream_mining.rs @@ -1,7 +1,4 @@ -#![allow(dead_code)] - -use core::convert::TryInto; -use std::sync::Arc; +use std::{convert::TryInto, sync::Arc}; use async_channel::{Receiver, SendError, Sender}; use tokio::{net::TcpListener, sync::oneshot::Receiver as TokioReceiver}; @@ -39,7 +36,6 @@ pub struct DownstreamMiningNode { receiver: Receiver, sender: Sender, pub status: DownstreamMiningNodeStatus, - pub prev_job_id: Option, upstream: Option>>, } @@ -61,14 +57,6 @@ pub enum Channel { DownstreamHomUpstreamExtended { data: CommonDownstreamData, channel_id: u32, - group_id: u32, - }, - // Below variant is not supported cause do not have much sense - // DowntreamNonHomUpstreamGroup { data: CommonDownstreamData, group_ids: Vec, extended_ids: Vec}, - DowntreamNonHomUpstreamExtended { - data: CommonDownstreamData, - group_ids: Vec, - extended_ids: Vec, }, } @@ -119,14 +107,13 @@ impl DownstreamMiningNodeStatus { } } - fn open_channel_for_down_hom_up_extended(&mut self, channel_id: u32, group_id: u32) { + fn open_channel_for_down_hom_up_extended(&mut self, channel_id: u32, _group_id: u32) { match self { DownstreamMiningNodeStatus::Initializing => panic!(), DownstreamMiningNodeStatus::Paired(data) => { let channel = Channel::DownstreamHomUpstreamExtended { data: *data, channel_id, - group_id, }; let self_ = Self::ChannelOpened(channel); let _ = std::mem::replace(self, self_); @@ -134,29 +121,6 @@ impl DownstreamMiningNodeStatus { DownstreamMiningNodeStatus::ChannelOpened(..) => panic!("Channel already opened"), } } - - fn add_extended_from_non_hom_for_up_extended(&mut self, id: u32) { - match self { - DownstreamMiningNodeStatus::Initializing => panic!(), - DownstreamMiningNodeStatus::Paired(data) => { - let channel = Channel::DowntreamNonHomUpstreamExtended { - data: *data, - group_ids: vec![], - extended_ids: vec![id], - }; - let self_ = Self::ChannelOpened(channel); - let _ = std::mem::replace(self, self_); - } - DownstreamMiningNodeStatus::ChannelOpened( - Channel::DowntreamNonHomUpstreamExtended { extended_ids, .. }, - ) => { - if !extended_ids.contains(&id) { - extended_ids.push(id) - } - } - _ => panic!(), - } - } } impl PartialEq for DownstreamMiningNode { @@ -179,16 +143,12 @@ impl DownstreamMiningNode { self.status .open_channel_for_down_hom_up_extended(channel_id, group_id); } - pub fn add_extended_from_non_hom_for_up_extended(&mut self, id: u32) { - self.status.add_extended_from_non_hom_for_up_extended(id); - } pub fn new(receiver: Receiver, sender: Sender, id: u32) -> Self { Self { receiver, sender, status: DownstreamMiningNodeStatus::Initializing, - prev_job_id: None, upstream: None, id, } @@ -430,12 +390,6 @@ impl let res = UpstreamMiningNode::handle_std_shr(remote.clone(), m).unwrap(); Ok(SendTo::Respond(res)) } - DownstreamMiningNodeStatus::ChannelOpened( - Channel::DowntreamNonHomUpstreamExtended { .. }, - ) => { - // unreachable cause the proxy do not support this kind of channel - unreachable!(); - } } } @@ -537,9 +491,6 @@ impl IsDownstream for DownstreamMiningNode { data, .. }) => data, - DownstreamMiningNodeStatus::ChannelOpened( - Channel::DowntreamNonHomUpstreamExtended { data, .. }, - ) => data, DownstreamMiningNodeStatus::ChannelOpened(Channel::DownstreamHomUpstreamExtended { data, .. diff --git a/roles/mining-proxy/src/lib/upstream_mining.rs b/roles/mining-proxy/src/lib/upstream_mining.rs index 96683d0f3..5ad012d10 100644 --- a/roles/mining-proxy/src/lib/upstream_mining.rs +++ b/roles/mining-proxy/src/lib/upstream_mining.rs @@ -474,7 +474,6 @@ impl UpstreamMiningNode { Channel::DownstreamHomUpstreamExtended { channel_id, .. } => { Some(*channel_id) } - Channel::DowntreamNonHomUpstreamExtended { .. } => todo!(), }, }) .unwrap()