From f10536c02d485960d7bd8546f53430c9434ad6a2 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Mon, 16 Sep 2024 17:18:43 +0300 Subject: [PATCH] feedback --- .../teku/infrastructure/logging/Converter.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java index cdc46acdeb7..595566b2e9a 100644 --- a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java +++ b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java @@ -23,17 +23,14 @@ public class Converter { - static BigDecimal gweiToEthFactor = BigDecimal.TEN.pow(9); - public static String weiToEth(final UInt256 wei) { - final BigDecimal result = Convert.fromWei(wei.toDecimalString(), Convert.Unit.ETHER); - return result.setScale(6, RoundingMode.HALF_UP).toString(); + final BigDecimal eth = Convert.fromWei(wei.toDecimalString(), Convert.Unit.ETHER); + return eth.setScale(6, RoundingMode.HALF_UP).toString(); } public static String gweiToEth(final UInt64 gwei) { - return new BigDecimal(gwei.bigIntegerValue()) - .divide(gweiToEthFactor, 6, RoundingMode.HALF_UP) - .toString(); + final BigDecimal wei = Convert.toWei(gwei.toString(), Unit.GWEI); + return weiToEth(UInt256.valueOf(wei.toBigInteger())); } public static UInt64 weiToGwei(final UInt256 wei) {