Skip to content

Commit e4d2dd1

Browse files
authored
Merge pull request #421 from Shourya742/2026-04-08-add-display-for-translator
Make sure to use display for types which implements it in Tproxy
2 parents 444cf55 + b5a36d5 commit e4d2dd1

File tree

6 files changed

+22
-28
lines changed

6 files changed

+22
-28
lines changed

miner-apps/translator/src/lib/sv1/downstream/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl DownstreamData {
8282
pub fn set_upstream_target(&mut self, upstream_target: Target, downstream_id: DownstreamId) {
8383
self.upstream_target = Some(upstream_target);
8484
debug!(
85-
"Downstream {downstream_id}: Set upstream target to {:?}",
85+
"Downstream {downstream_id}: Set upstream target to {}",
8686
upstream_target
8787
);
8888
}

miner-apps/translator/src/lib/sv1/sv1_server/difficulty_manager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ impl Sv1Server {
113113
// Case 1: new_target >= upstream_target, send set_difficulty
114114
// immediately
115115
trace!(
116-
"✅ Target comparison: new_target ({:?}) >= upstream_target ({:?}) for downstream {}, will send set_difficulty immediately",
116+
"✅ Target comparison: new_target ({}) >= upstream_target ({}) for downstream {}, will send set_difficulty immediately",
117117
new_target, upstream_target, downstream_id
118118
);
119119
immediate_updates.push((channel_id, Some(*downstream_id), new_target));
120120
} else {
121121
// Case 2: new_target < upstream_target, delay set_difficulty until
122122
// SetTarget
123123
trace!(
124-
"⏳ Target comparison: new_target ({:?}) < upstream_target ({:?}) for downstream {}, will delay set_difficulty until SetTarget",
124+
"⏳ Target comparison: new_target ({}) < upstream_target ({}) for downstream {}, will delay set_difficulty until SetTarget",
125125
new_target, upstream_target, downstream_id
126126
);
127127
self.pending_target_updates.super_safe_lock(|data| {
@@ -240,7 +240,7 @@ impl Sv1Server {
240240
};
241241

242242
debug!(
243-
"Sending aggregated UpdateChannel: channel_id={}, total_hashrate={}, min_target={:?}, downstreams={}, vardiff_updates={}",
243+
"Sending aggregated UpdateChannel: channel_id={}, total_hashrate={}, min_target={}, downstreams={}, vardiff_updates={}",
244244
channel_id,
245245
total_hashrate,
246246
min_target,
@@ -270,7 +270,7 @@ impl Sv1Server {
270270
};
271271

272272
debug!(
273-
"Sending UpdateChannel for downstream {}: channel_id={}, hashrate={}, target={:?}",
273+
"Sending UpdateChannel for downstream {}: channel_id={}, hashrate={}, target={}",
274274
downstream_id, channel_id, new_hashrate, new_target
275275
);
276276

@@ -297,7 +297,7 @@ impl Sv1Server {
297297
let new_upstream_target =
298298
Target::from_le_bytes(set_target.maximum_target.inner_as_ref().try_into().unwrap());
299299
debug!(
300-
"Received SetTarget for channel {}: new_upstream_target = {:?}",
300+
"Received SetTarget for channel {}: new_upstream_target = {}",
301301
set_target.channel_id, new_upstream_target
302302
);
303303

@@ -406,7 +406,7 @@ impl Sv1Server {
406406
} else {
407407
// WARNING: Upstream gave us a target higher than what we requested
408408
error!(
409-
"❌ Protocol issue: SetTarget response has target ({:?}) which is higher than requested target ({:?}) in UpdateChannel for channel {:?}. Ignoring this pending update for downstream {:?}.",
409+
"❌ Protocol issue: SetTarget response has target ({}) which is higher than requested target ({}) in UpdateChannel for channel {}. Ignoring this pending update for downstream {}.",
410410
new_upstream_target, pending_update.new_target, channel_id, pending_update.downstream_id
411411
);
412412
false // remove from pending list (don't keep invalid requests)

miner-apps/translator/src/lib/sv1/sv1_server/downstream_message_handler.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ impl IsServer<'static> for Sv1Server {
2323
let downstream_id = client_id.expect("Downstream id should exist");
2424

2525
info!("Received mining.configure from SV1 downstream");
26-
debug!(
27-
"Downstream {downstream_id}: mining.configure = {:?}",
28-
request
29-
);
26+
debug!("Downstream {downstream_id}: mining.configure = {}", request);
3027

3128
let downstream = self
3229
.downstreams
@@ -66,7 +63,7 @@ impl IsServer<'static> for Sv1Server {
6663
let downstream_id = client_id.expect("Downstream id should exist");
6764

6865
info!("Received mining.subscribe from Sv1 downstream");
69-
debug!("Down: Handling mining.subscribe: {:?}", request);
66+
debug!("Down: Handling mining.subscribe: {}", request);
7067

7168
let set_difficulty_sub = (
7269
"mining.set_difficulty".to_string(),
@@ -88,7 +85,7 @@ impl IsServer<'static> for Sv1Server {
8885
) -> bool {
8986
let downstream_id = client_id.expect("Downstream id should exist");
9087
info!("Received mining.authorize from Sv1 downstream {downstream_id}");
91-
debug!("Down: Handling mining.authorize: {:?}", request);
88+
debug!("Down: Handling mining.authorize: {}", request);
9289
true
9390
}
9491

miner-apps/translator/src/lib/sv1/sv1_server/sv1_server.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,7 @@ impl Sv1Server {
356356

357357
match response {
358358
Ok(Some(response_msg)) => {
359-
debug!(
360-
"Down: Sending Sv1 message to downstream: {:?}",
361-
response_msg
362-
);
359+
debug!("Down: Sending Sv1 message to downstream: {}", response_msg);
363360
downstream
364361
.downstream_channel_state
365362
.downstream_sv1_sender
@@ -877,7 +874,7 @@ impl Sv1Server {
877874
let new_target =
878875
Target::from_le_bytes(set_target.maximum_target.inner_as_ref().try_into().unwrap());
879876
debug!(
880-
"Forwarding SetTarget to downstreams: channel_id={}, target={:?}",
877+
"Forwarding SetTarget to downstreams: channel_id={}, target={}",
881878
set_target.channel_id, new_target
882879
);
883880

miner-apps/translator/src/lib/sv2/channel_manager/channel_manager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl ChannelManager {
372372
}
373373

374374
info!(
375-
"Sending OpenExtendedMiningChannel message to upstream: {:?}",
375+
"Sending OpenExtendedMiningChannel message to upstream: {}",
376376
open_channel_msg
377377
);
378378

@@ -524,7 +524,7 @@ impl ChannelManager {
524524
let sv2_frame = StandardSv2Frame::from_bytes(frame_bytes.into())
525525
.map_err(|missing| {
526526
error!(
527-
"Failed to convert frame bytes to StandardSv2Frame: {:?}",
527+
"Failed to convert frame bytes to StandardSv2Frame: {}",
528528
missing
529529
);
530530
TproxyError::shutdown(framing_sv2::Error::ExpectedSv2Frame)
@@ -550,7 +550,7 @@ impl ChannelManager {
550550
}
551551
}
552552
Mining::UpdateChannel(mut m) => {
553-
debug!("Received UpdateChannel from SV1Server: {:?}", m);
553+
debug!("Received UpdateChannel from SV1Server: {}", m);
554554

555555
if is_aggregated() {
556556
// Update the aggregated channel's nominal hashrate so
@@ -570,7 +570,7 @@ impl ChannelManager {
570570
}
571571

572572
info!(
573-
"Sending UpdateChannel message to upstream for channel_id: {:?}",
573+
"Sending UpdateChannel message to upstream for channel_id: {}",
574574
m.channel_id
575575
);
576576
// Forward UpdateChannel message to upstream
@@ -620,7 +620,7 @@ impl ChannelManager {
620620
})?;
621621
}
622622
_ => {
623-
warn!("Unhandled downstream message: {:?}", message);
623+
warn!("Unhandled downstream message: {}", message);
624624
}
625625
}
626626

miner-apps/translator/src/lib/sv2/upstream/upstream.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,16 @@ impl Upstream {
283283
requested_extensions: Seq064K::new(self.required_extensions.clone()).unwrap(),
284284
};
285285

286+
info!(
287+
"Sending RequestExtensions message to upstream: {}",
288+
require_extensions
289+
);
290+
286291
let sv2_frame: Sv2Frame =
287292
AnyMessage::Extensions(require_extensions.into_static().into())
288293
.try_into()
289294
.map_err(TproxyError::shutdown)?;
290295

291-
info!(
292-
"Sending RequestExtensions message to upstream: {:?}",
293-
sv2_frame
294-
);
295-
296296
self.upstream_channel_state
297297
.upstream_sender
298298
.send(sv2_frame)

0 commit comments

Comments
 (0)