From 74591654aa71dbbd283e5a37e0c9e7824b7122bd Mon Sep 17 00:00:00 2001 From: jbesraa Date: Tue, 18 Jun 2024 15:17:26 +0300 Subject: [PATCH] Remove `Frame` trait The `Frame` trait is used solely by a single struct and it is only adding biolerplate to the code without benifits. We could consider re-adding it in the future if needed. --- .../src/sv2/criterion_sv2_benchmark.rs | 2 +- benches/benches/src/sv2/iai_sv2_benchmark.rs | 2 +- examples/interop-cpp/src/main.rs | 2 +- examples/ping-pong-with-noise/src/node.rs | 2 +- examples/ping-pong-without-noise/src/node.rs | 2 +- examples/template-provider-test/src/main.rs | 2 +- protocols/fuzz-tests/src/main.rs | 2 +- protocols/v2/codec-sv2/src/decoder.rs | 2 +- protocols/v2/codec-sv2/src/encoder.rs | 2 +- protocols/v2/codec-sv2/src/lib.rs | 2 +- protocols/v2/framing-sv2/src/framing2.rs | 78 ++++--------------- protocols/v2/roles-logic-sv2/src/parsers.rs | 2 +- protocols/v2/sv2-ffi/src/lib.rs | 2 +- roles/jd-client/src/lib/downstream.rs | 2 +- roles/jd-client/src/lib/job_declarator/mod.rs | 1 - .../lib/job_declarator/setup_connection.rs | 2 +- .../src/lib/template_receiver/mod.rs | 2 +- .../lib/template_receiver/setup_connection.rs | 2 +- .../src/lib/upstream_sv2/upstream.rs | 2 +- roles/jd-server/src/lib/job_declarator/mod.rs | 2 +- .../mining-proxy/src/lib/downstream_mining.rs | 2 +- roles/mining-proxy/src/lib/upstream_mining.rs | 2 +- roles/pool/src/lib/mining_pool/mod.rs | 2 +- .../src/lib/mining_pool/setup_connection.rs | 1 - roles/pool/src/lib/template_receiver/mod.rs | 2 +- .../lib/template_receiver/setup_connection.rs | 1 - roles/test-utils/mining-device/src/main.rs | 2 +- .../src/lib/upstream_sv2/upstream.rs | 2 +- utils/message-generator/src/executor.rs | 2 +- utils/message-generator/src/main.rs | 2 +- utils/message-generator/src/parser/frames.rs | 2 +- 31 files changed, 41 insertions(+), 94 deletions(-) diff --git a/benches/benches/src/sv2/criterion_sv2_benchmark.rs b/benches/benches/src/sv2/criterion_sv2_benchmark.rs index 7aa35f158..18fab853d 100644 --- a/benches/benches/src/sv2/criterion_sv2_benchmark.rs +++ b/benches/benches/src/sv2/criterion_sv2_benchmark.rs @@ -1,4 +1,4 @@ -use codec_sv2::{Frame, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; use criterion::{black_box, Criterion}; use roles_logic_sv2::{ handlers::{common::ParseUpstreamCommonMessages, mining::ParseUpstreamMiningMessages}, diff --git a/benches/benches/src/sv2/iai_sv2_benchmark.rs b/benches/benches/src/sv2/iai_sv2_benchmark.rs index 2cab39cc4..b049b9dc4 100644 --- a/benches/benches/src/sv2/iai_sv2_benchmark.rs +++ b/benches/benches/src/sv2/iai_sv2_benchmark.rs @@ -1,4 +1,4 @@ -use codec_sv2::{Frame, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; use iai::{black_box, main}; use roles_logic_sv2::{ handlers::{common::ParseUpstreamCommonMessages, mining::ParseUpstreamMiningMessages, SendTo_}, diff --git a/examples/interop-cpp/src/main.rs b/examples/interop-cpp/src/main.rs index 34f6bef09..09950e94b 100644 --- a/examples/interop-cpp/src/main.rs +++ b/examples/interop-cpp/src/main.rs @@ -12,7 +12,7 @@ mod main_ { #[cfg(not(feature = "with_serde"))] mod main_ { - use codec_sv2::{Encoder, Frame, StandardDecoder, StandardSv2Frame}; + use codec_sv2::{Encoder, StandardDecoder, StandardSv2Frame}; use common_messages_sv2::{Protocol, SetupConnection, SetupConnectionError}; use const_sv2::{ CHANNEL_BIT_SETUP_CONNECTION, MESSAGE_TYPE_SETUP_CONNECTION, diff --git a/examples/ping-pong-with-noise/src/node.rs b/examples/ping-pong-with-noise/src/node.rs index 912d6e835..1ae042aa8 100644 --- a/examples/ping-pong-with-noise/src/node.rs +++ b/examples/ping-pong-with-noise/src/node.rs @@ -11,7 +11,7 @@ use async_std::{ }; use core::convert::TryInto; -use codec_sv2::{Frame, HandshakeRole, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{HandshakeRole, StandardEitherFrame, StandardSv2Frame}; use std::time; diff --git a/examples/ping-pong-without-noise/src/node.rs b/examples/ping-pong-without-noise/src/node.rs index 97295d591..21edf617e 100644 --- a/examples/ping-pong-without-noise/src/node.rs +++ b/examples/ping-pong-without-noise/src/node.rs @@ -10,7 +10,7 @@ use async_std::{ task, }; -use codec_sv2::{Frame, StandardDecoder, StandardSv2Frame}; +use codec_sv2::{StandardDecoder, StandardSv2Frame}; #[derive(Debug)] enum Expected { diff --git a/examples/template-provider-test/src/main.rs b/examples/template-provider-test/src/main.rs index 78878227b..5a83aa39a 100644 --- a/examples/template-provider-test/src/main.rs +++ b/examples/template-provider-test/src/main.rs @@ -1,6 +1,6 @@ use async_channel::{Receiver, Sender}; use async_std::net::TcpStream; -use codec_sv2::{Frame, StandardEitherFrame, StandardSv2Frame, Sv2Frame}; +use codec_sv2::{StandardEitherFrame, StandardSv2Frame, Sv2Frame}; use network_helpers::PlainConnection; use roles_logic_sv2::{ parsers::{IsSv2Message, TemplateDistribution}, diff --git a/protocols/fuzz-tests/src/main.rs b/protocols/fuzz-tests/src/main.rs index c9623ecb5..bb2364c0f 100644 --- a/protocols/fuzz-tests/src/main.rs +++ b/protocols/fuzz-tests/src/main.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; use binary_codec_sv2::{Seq064K,U256,B0255,Seq0255}; use binary_codec_sv2::from_bytes; -use codec_sv2::{StandardDecoder,Sv2Frame,Frame}; +use codec_sv2::{StandardDecoder,Sv2Frame}; use roles_logic_sv2::parsers::PoolMessages; type F = Sv2Frame,Vec>; diff --git a/protocols/v2/codec-sv2/src/decoder.rs b/protocols/v2/codec-sv2/src/decoder.rs index aebc0aee1..4a946a1e1 100644 --- a/protocols/v2/codec-sv2/src/decoder.rs +++ b/protocols/v2/codec-sv2/src/decoder.rs @@ -12,7 +12,7 @@ use framing_sv2::framing2::HandShakeFrame; #[cfg(feature = "noise_sv2")] use framing_sv2::header::{NOISE_HEADER_ENCRYPTED_SIZE, NOISE_HEADER_SIZE}; use framing_sv2::{ - framing2::{EitherFrame, Frame as F_, Sv2Frame}, + framing2::{EitherFrame, Sv2Frame}, header::Header, }; #[cfg(feature = "noise_sv2")] diff --git a/protocols/v2/codec-sv2/src/encoder.rs b/protocols/v2/codec-sv2/src/encoder.rs index a12342217..9ecc37c3e 100644 --- a/protocols/v2/codec-sv2/src/encoder.rs +++ b/protocols/v2/codec-sv2/src/encoder.rs @@ -5,9 +5,9 @@ pub use const_sv2::{AEAD_MAC_LEN, SV2_FRAME_CHUNK_SIZE, SV2_FRAME_HEADER_SIZE}; #[cfg(feature = "noise_sv2")] use core::convert::TryInto; use core::marker::PhantomData; +use framing_sv2::framing2::Sv2Frame; #[cfg(feature = "noise_sv2")] use framing_sv2::framing2::{EitherFrame, HandShakeFrame}; -use framing_sv2::framing2::{Frame as F_, Sv2Frame}; #[allow(unused_imports)] pub use framing_sv2::header::NOISE_HEADER_ENCRYPTED_SIZE; diff --git a/protocols/v2/codec-sv2/src/lib.rs b/protocols/v2/codec-sv2/src/lib.rs index f5cbc013d..184c39fda 100644 --- a/protocols/v2/codec-sv2/src/lib.rs +++ b/protocols/v2/codec-sv2/src/lib.rs @@ -23,7 +23,7 @@ pub use encoder::NoiseEncoder; #[cfg(feature = "noise_sv2")] pub use framing_sv2::framing2::HandShakeFrame; -pub use framing_sv2::framing2::{Frame, Sv2Frame}; +pub use framing_sv2::framing2::Sv2Frame; #[cfg(feature = "noise_sv2")] pub use noise_sv2::{self, Initiator, NoiseCodec, Responder}; diff --git a/protocols/v2/framing-sv2/src/framing2.rs b/protocols/v2/framing-sv2/src/framing2.rs index 692a22af4..eec461fa9 100644 --- a/protocols/v2/framing-sv2/src/framing2.rs +++ b/protocols/v2/framing-sv2/src/framing2.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use crate::{ header::{Header, NOISE_HEADER_LEN_OFFSET, NOISE_HEADER_SIZE}, Error, @@ -29,51 +30,6 @@ impl Sv2Frame { } } -pub trait Frame<'a, T: Serialize + GetSize>: Sized { - type Buffer: AsMut<[u8]>; - type Deserialized; - - /// Write the serialized `Frame` into `dst`. - fn serialize(self, dst: &mut [u8]) -> Result<(), Error>; - - /// Get the payload - fn payload(&'a mut self) -> &'a mut [u8]; - - /// Returns `Some(self.header)` when the frame has a header (`Sv2Frame`), returns `None` where it doesn't (`HandShakeFrame`). - fn get_header(&self) -> Option; - - /// Try to build a `Frame` from raw bytes. - /// Checks if the payload has the correct size (as stated in the `Header`). - /// Returns `Self` on success, or the number of the bytes needed to complete the frame - /// as an error. Nothing is assumed or checked about the correctness of the payload. - fn from_bytes(bytes: Self::Buffer) -> Result; - - /// Builds a `Frame` from raw bytes. - /// Does not check if the payload has the correct size (as stated in the `Header`). - /// Nothing is assumed or checked about the correctness of the payload. - fn from_bytes_unchecked(bytes: Self::Buffer) -> Self; - - /// Helps to determine if the frame size encoded in a byte array correctly representing the size of the frame. - /// - Returns `0` if the byte slice is of the expected size according to the header. - /// - Returns a negative value if the byte slice is smaller than a Noise Frame header; this value - /// represents how many bytes are missing. - /// - Returns a positive value if the byte slice is longer than expected; this value - /// indicates the surplus of bytes beyond the expected size. - fn size_hint(bytes: &[u8]) -> isize; - - /// Returns the size of the `Frame` payload. - fn encoded_length(&self) -> usize; - - /// Try to build a `Frame` from a serializable payload. - /// Returns `Some(Self)` if the size of the payload fits in the frame, `None` otherwise. - fn from_message( - message: T, - message_type: u8, - extension_type: u16, - channel_msg: bool, - ) -> Option; -} - /// Abstraction for a SV2 Frame. #[derive(Debug, Clone)] pub struct Sv2Frame { @@ -98,15 +54,12 @@ impl HandShakeFrame { } } -impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for Sv2Frame { - type Buffer = B; - type Deserialized = B; - +impl + AsRef<[u8]>> Sv2Frame { /// Write the serialized `Sv2Frame` into `dst`. /// This operation when called on an already serialized frame is very cheap. /// When called on a non serialized frame, it is not so cheap (because it serializes it). #[inline] - fn serialize(self, dst: &mut [u8]) -> Result<(), Error> { + pub fn serialize(self, dst: &mut [u8]) -> Result<(), Error> { if let Some(mut serialized) = self.serialized { dst.swap_with_slice(serialized.as_mut()); Ok(()) @@ -132,7 +85,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for /// This function is only intended as a fast way to get a reference to an /// already serialized payload. If the frame has not yet been /// serialized, this function should never be used (it will panic). - fn payload(&'a mut self) -> &'a mut [u8] { + pub fn payload(&mut self) -> &mut [u8] { if let Some(serialized) = self.serialized.as_mut() { &mut serialized.as_mut()[Header::SIZE..] } else { @@ -142,7 +95,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for } /// `Sv2Frame` always returns `Some(self.header)`. - fn get_header(&self) -> Option { + pub fn get_header(&self) -> Option { Some(self.header) } @@ -150,7 +103,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for /// Returns a `Sv2Frame` on success, or the number of the bytes needed to complete the frame /// as an error. `Self.serialized` is `Some`, but nothing is assumed or checked about the correctness of the payload. #[inline] - fn from_bytes(mut bytes: Self::Buffer) -> Result { + pub fn from_bytes(mut bytes: B) -> Result { let hint = Self::size_hint(bytes.as_mut()); if hint == 0 { @@ -161,7 +114,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for } #[inline] - fn from_bytes_unchecked(mut bytes: Self::Buffer) -> Self { + pub fn from_bytes_unchecked(mut bytes: B) -> Self { // Unchecked function caller is supposed to already know that the passed bytes are valid let header = Header::from_bytes(bytes.as_mut()).expect("Invalid header"); Self { @@ -179,7 +132,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for /// - Returns a positive value if the byte slice is longer than expected; this value /// indicates the surplus of bytes beyond the expected size. #[inline] - fn size_hint(bytes: &[u8]) -> isize { + pub fn size_hint(bytes: &[u8]) -> isize { match Header::from_bytes(bytes) { Err(_) => { // Returns how many bytes are missing from the expected frame size @@ -200,7 +153,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for /// If `Sv2Frame` is serialized, returns the length of `self.serialized`, /// otherwise, returns the length of `self.payload`. #[inline] - fn encoded_length(&self) -> usize { + pub fn encoded_length(&self) -> usize { if let Some(serialized) = self.serialized.as_ref() { serialized.as_ref().len() } else if let Some(payload) = self.payload.as_ref() { @@ -213,7 +166,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for /// Tries to build a `Sv2Frame` from a non-serialized payload. /// Returns a `Sv2Frame` if the size of the payload fits in the frame, `None` otherwise. - fn from_message( + pub fn from_message( message: T, message_type: u8, extension_type: u16, @@ -229,10 +182,7 @@ impl<'a, T: Serialize + GetSize, B: AsMut<[u8]> + AsRef<[u8]>> Frame<'a, T> for } } -impl<'a> Frame<'a, Slice> for HandShakeFrame { - type Buffer = Slice; - type Deserialized = &'a mut [u8]; - +impl HandShakeFrame { /// Put the Noise Frame payload into `dst` #[inline] fn serialize(mut self, dst: &mut [u8]) -> Result<(), Error> { @@ -242,7 +192,7 @@ impl<'a> Frame<'a, Slice> for HandShakeFrame { /// Get the Noise Frame payload #[inline] - fn payload(&'a mut self) -> &'a mut [u8] { + fn payload(&mut self) -> &mut [u8] { &mut self.payload[NOISE_HEADER_SIZE..] } @@ -252,12 +202,12 @@ impl<'a> Frame<'a, Slice> for HandShakeFrame { } /// Builds a `HandShakeFrame` from raw bytes. Nothing is assumed or checked about the correctness of the payload. - fn from_bytes(bytes: Self::Buffer) -> Result { + pub fn from_bytes(bytes: Slice) -> Result { Ok(Self::from_bytes_unchecked(bytes)) } #[inline] - fn from_bytes_unchecked(bytes: Self::Buffer) -> Self { + pub fn from_bytes_unchecked(bytes: Slice) -> Self { Self { payload: bytes } } diff --git a/protocols/v2/roles-logic-sv2/src/parsers.rs b/protocols/v2/roles-logic-sv2/src/parsers.rs index 6eaf5e016..4d80387c9 100644 --- a/protocols/v2/roles-logic-sv2/src/parsers.rs +++ b/protocols/v2/roles-logic-sv2/src/parsers.rs @@ -13,7 +13,7 @@ use binary_sv2::GetSize; use binary_sv2::{from_bytes, Deserialize}; -use framing_sv2::framing2::{Frame, Sv2Frame}; +use framing_sv2::framing2::Sv2Frame; use const_sv2::{ CHANNEL_BIT_ALLOCATE_MINING_JOB_TOKEN, CHANNEL_BIT_ALLOCATE_MINING_JOB_TOKEN_SUCCESS, diff --git a/protocols/v2/sv2-ffi/src/lib.rs b/protocols/v2/sv2-ffi/src/lib.rs index 346d497b9..9befa0ca7 100644 --- a/protocols/v2/sv2-ffi/src/lib.rs +++ b/protocols/v2/sv2-ffi/src/lib.rs @@ -4,7 +4,7 @@ use std::{ fmt::{Display, Formatter}, }; -use codec_sv2::{Encoder, Frame, StandardDecoder, StandardSv2Frame}; +use codec_sv2::{Encoder, StandardDecoder, StandardSv2Frame}; use common_messages_sv2::{ CSetupConnection, CSetupConnectionError, ChannelEndpointChanged, SetupConnection, SetupConnectionError, SetupConnectionSuccess, diff --git a/roles/jd-client/src/lib/downstream.rs b/roles/jd-client/src/lib/downstream.rs index ddc6e5bd0..8f0a7be88 100644 --- a/roles/jd-client/src/lib/downstream.rs +++ b/roles/jd-client/src/lib/downstream.rs @@ -21,7 +21,7 @@ use roles_logic_sv2::{ }; use tracing::{debug, error, info, warn}; -use codec_sv2::{Frame, HandshakeRole, Responder, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{HandshakeRole, Responder, StandardEitherFrame, StandardSv2Frame}; use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; use stratum_common::bitcoin::{consensus::Decodable, TxOut}; diff --git a/roles/jd-client/src/lib/job_declarator/mod.rs b/roles/jd-client/src/lib/job_declarator/mod.rs index abaf852ca..43f6c8ea5 100644 --- a/roles/jd-client/src/lib/job_declarator/mod.rs +++ b/roles/jd-client/src/lib/job_declarator/mod.rs @@ -17,7 +17,6 @@ use tokio::task::AbortHandle; use tracing::{error, info}; use async_recursion::async_recursion; -use codec_sv2::Frame; use nohash_hasher::BuildNoHashHasher; use roles_logic_sv2::{ handlers::job_declaration::ParseServerJobDeclarationMessages, diff --git a/roles/jd-client/src/lib/job_declarator/setup_connection.rs b/roles/jd-client/src/lib/job_declarator/setup_connection.rs index 063592c40..0e7b6fd8a 100644 --- a/roles/jd-client/src/lib/job_declarator/setup_connection.rs +++ b/roles/jd-client/src/lib/job_declarator/setup_connection.rs @@ -1,5 +1,5 @@ use async_channel::{Receiver, Sender}; -use codec_sv2::{Frame, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; use roles_logic_sv2::{ common_messages_sv2::{Protocol, SetupConnection}, handlers::common::{ParseUpstreamCommonMessages, SendTo}, diff --git a/roles/jd-client/src/lib/template_receiver/mod.rs b/roles/jd-client/src/lib/template_receiver/mod.rs index 02d3d0497..f418318a8 100644 --- a/roles/jd-client/src/lib/template_receiver/mod.rs +++ b/roles/jd-client/src/lib/template_receiver/mod.rs @@ -1,6 +1,6 @@ use super::{job_declarator::JobDeclarator, status, PoolChangerTrigger}; use async_channel::{Receiver, Sender}; -use codec_sv2::{Frame, HandshakeRole, Initiator, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{HandshakeRole, Initiator, StandardEitherFrame, StandardSv2Frame}; use error_handling::handle_result; use key_utils::Secp256k1PublicKey; use network_helpers_sv2::noise_connection_tokio::Connection; diff --git a/roles/jd-client/src/lib/template_receiver/setup_connection.rs b/roles/jd-client/src/lib/template_receiver/setup_connection.rs index 45f48a2f4..505b945c3 100644 --- a/roles/jd-client/src/lib/template_receiver/setup_connection.rs +++ b/roles/jd-client/src/lib/template_receiver/setup_connection.rs @@ -1,5 +1,5 @@ use async_channel::{Receiver, Sender}; -use codec_sv2::{Frame, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; use roles_logic_sv2::{ common_messages_sv2::{Protocol, SetupConnection}, handlers::common::{ParseUpstreamCommonMessages, SendTo}, diff --git a/roles/jd-client/src/lib/upstream_sv2/upstream.rs b/roles/jd-client/src/lib/upstream_sv2/upstream.rs index 857cbd308..b04efa335 100644 --- a/roles/jd-client/src/lib/upstream_sv2/upstream.rs +++ b/roles/jd-client/src/lib/upstream_sv2/upstream.rs @@ -11,7 +11,7 @@ use super::super::{ }; use async_channel::{Receiver, Sender}; use binary_sv2::{Seq0255, U256}; -use codec_sv2::{Frame, HandshakeRole, Initiator}; +use codec_sv2::{HandshakeRole, Initiator}; use error_handling::handle_result; use key_utils::Secp256k1PublicKey; use network_helpers_sv2::noise_connection_tokio::Connection; diff --git a/roles/jd-server/src/lib/job_declarator/mod.rs b/roles/jd-server/src/lib/job_declarator/mod.rs index 56d56223c..34d9e66de 100644 --- a/roles/jd-server/src/lib/job_declarator/mod.rs +++ b/roles/jd-server/src/lib/job_declarator/mod.rs @@ -2,7 +2,7 @@ pub mod message_handler; use super::{error::JdsError, mempool::JDsMempool, status, Configuration, EitherFrame, StdFrame}; use async_channel::{Receiver, Sender}; use binary_sv2::{B0255, U256}; -use codec_sv2::{Frame, HandshakeRole, Responder}; +use codec_sv2::{HandshakeRole, Responder}; use error_handling::handle_result; use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey, SignatureService}; use network_helpers_sv2::noise_connection_tokio::Connection; diff --git a/roles/mining-proxy/src/lib/downstream_mining.rs b/roles/mining-proxy/src/lib/downstream_mining.rs index d4e9bcb17..188055119 100644 --- a/roles/mining-proxy/src/lib/downstream_mining.rs +++ b/roles/mining-proxy/src/lib/downstream_mining.rs @@ -17,7 +17,7 @@ use roles_logic_sv2::{ }; use tracing::info; -use codec_sv2::{Frame, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{StandardEitherFrame, StandardSv2Frame}; pub type Message = MiningDeviceMessages<'static>; pub type StdFrame = StandardSv2Frame; diff --git a/roles/mining-proxy/src/lib/upstream_mining.rs b/roles/mining-proxy/src/lib/upstream_mining.rs index 61a5d0f31..e3f6eef99 100644 --- a/roles/mining-proxy/src/lib/upstream_mining.rs +++ b/roles/mining-proxy/src/lib/upstream_mining.rs @@ -6,7 +6,7 @@ use roles_logic_sv2::utils::Id; use super::downstream_mining::{Channel, DownstreamMiningNode, StdFrame as DownstreamFrame}; use async_channel::{Receiver, SendError, Sender}; use async_recursion::async_recursion; -use codec_sv2::{Frame, HandshakeRole, Initiator, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{HandshakeRole, Initiator, StandardEitherFrame, StandardSv2Frame}; use network_helpers_sv2::noise_connection_tokio::Connection; use nohash_hasher::BuildNoHashHasher; use roles_logic_sv2::{ diff --git a/roles/pool/src/lib/mining_pool/mod.rs b/roles/pool/src/lib/mining_pool/mod.rs index e189c5406..4b9d10b18 100644 --- a/roles/pool/src/lib/mining_pool/mod.rs +++ b/roles/pool/src/lib/mining_pool/mod.rs @@ -4,7 +4,7 @@ use super::{ }; use async_channel::{Receiver, Sender}; use binary_sv2::U256; -use codec_sv2::{Frame, HandshakeRole, Responder, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{HandshakeRole, Responder, StandardEitherFrame, StandardSv2Frame}; use error_handling::handle_result; use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey, SignatureService}; use network_helpers_sv2::noise_connection_tokio::Connection; diff --git a/roles/pool/src/lib/mining_pool/setup_connection.rs b/roles/pool/src/lib/mining_pool/setup_connection.rs index cf2c06022..f0c47e9a8 100644 --- a/roles/pool/src/lib/mining_pool/setup_connection.rs +++ b/roles/pool/src/lib/mining_pool/setup_connection.rs @@ -3,7 +3,6 @@ use super::super::{ mining_pool::{EitherFrame, StdFrame}, }; use async_channel::{Receiver, Sender}; -use codec_sv2::Frame; use roles_logic_sv2::{ common_messages_sv2::{ has_requires_std_job, has_version_rolling, has_work_selection, SetupConnection, diff --git a/roles/pool/src/lib/template_receiver/mod.rs b/roles/pool/src/lib/template_receiver/mod.rs index 49d58e82a..2eeaa554f 100644 --- a/roles/pool/src/lib/template_receiver/mod.rs +++ b/roles/pool/src/lib/template_receiver/mod.rs @@ -4,7 +4,7 @@ use super::{ status, }; use async_channel::{Receiver, Sender}; -use codec_sv2::{Frame, HandshakeRole, Initiator}; +use codec_sv2::{HandshakeRole, Initiator}; use error_handling::handle_result; use key_utils::Secp256k1PublicKey; use network_helpers_sv2::noise_connection_tokio::Connection; diff --git a/roles/pool/src/lib/template_receiver/setup_connection.rs b/roles/pool/src/lib/template_receiver/setup_connection.rs index 60c3cb4f8..6687eadc6 100644 --- a/roles/pool/src/lib/template_receiver/setup_connection.rs +++ b/roles/pool/src/lib/template_receiver/setup_connection.rs @@ -3,7 +3,6 @@ use super::super::{ mining_pool::{EitherFrame, StdFrame}, }; use async_channel::{Receiver, Sender}; -use codec_sv2::Frame; use roles_logic_sv2::{ common_messages_sv2::{Protocol, SetupConnection}, errors::Error, diff --git a/roles/test-utils/mining-device/src/main.rs b/roles/test-utils/mining-device/src/main.rs index 1bfbf6737..763f83af5 100644 --- a/roles/test-utils/mining-device/src/main.rs +++ b/roles/test-utils/mining-device/src/main.rs @@ -110,7 +110,7 @@ async fn main() { use async_channel::{Receiver, Sender}; use binary_sv2::u256_from_int; -use codec_sv2::{Frame, Initiator, StandardEitherFrame, StandardSv2Frame}; +use codec_sv2::{Initiator, StandardEitherFrame, StandardSv2Frame}; use roles_logic_sv2::{ common_messages_sv2::{Protocol, SetupConnection, SetupConnectionSuccess}, common_properties::{IsMiningUpstream, IsUpstream}, diff --git a/roles/translator/src/lib/upstream_sv2/upstream.rs b/roles/translator/src/lib/upstream_sv2/upstream.rs index f6d192f75..6aab5978e 100644 --- a/roles/translator/src/lib/upstream_sv2/upstream.rs +++ b/roles/translator/src/lib/upstream_sv2/upstream.rs @@ -11,7 +11,7 @@ use crate::{ use async_channel::{Receiver, Sender}; use async_std::{net::TcpStream, task}; use binary_sv2::u256_from_int; -use codec_sv2::{Frame, HandshakeRole, Initiator}; +use codec_sv2::{HandshakeRole, Initiator}; use error_handling::handle_result; use key_utils::Secp256k1PublicKey; use network_helpers_sv2::Connection; diff --git a/utils/message-generator/src/executor.rs b/utils/message-generator/src/executor.rs index b69bce0e6..f31991eca 100644 --- a/utils/message-generator/src/executor.rs +++ b/utils/message-generator/src/executor.rs @@ -7,7 +7,7 @@ use crate::{ }; use async_channel::{Receiver, Sender}; use binary_sv2::Serialize; -use codec_sv2::{Frame, StandardEitherFrame as EitherFrame, Sv2Frame}; +use codec_sv2::{StandardEitherFrame as EitherFrame, Sv2Frame}; use roles_logic_sv2::parsers::{self, AnyMessage}; use std::{collections::HashMap, convert::TryInto, sync::Arc}; diff --git a/utils/message-generator/src/main.rs b/utils/message-generator/src/main.rs index 695b3919c..e2633ed23 100644 --- a/utils/message-generator/src/main.rs +++ b/utils/message-generator/src/main.rs @@ -451,7 +451,7 @@ mod test { into_static::into_static, net::{setup_as_downstream, setup_as_upstream}, }; - use codec_sv2::{Frame, Sv2Frame}; + use codec_sv2::Sv2Frame; use roles_logic_sv2::{ mining_sv2::{ CloseChannel, NewExtendedMiningJob, OpenExtendedMiningChannel, diff --git a/utils/message-generator/src/parser/frames.rs b/utils/message-generator/src/parser/frames.rs index 633163200..cd4c2c582 100644 --- a/utils/message-generator/src/parser/frames.rs +++ b/utils/message-generator/src/parser/frames.rs @@ -1,5 +1,5 @@ use super::sv2_messages::{message_from_path, ReplaceField}; -use codec_sv2::{buffer_sv2::Slice, Frame as _Frame, Sv2Frame}; +use codec_sv2::{buffer_sv2::Slice, Sv2Frame}; use roles_logic_sv2::parsers::AnyMessage; use serde_json::{Map, Value}; use std::{collections::HashMap, convert::TryInto};