From 56440a82e920d81915a4c9b831a4873eff721b13 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Thu, 24 Oct 2024 19:50:19 +0200 Subject: [PATCH] Tiny `getTopic` optimization (#8776) --- .../gossip/topics/topichandlers/Eth2TopicHandler.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/Eth2TopicHandler.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/Eth2TopicHandler.java index fd0f90dc8c4..27b3fcd59a3 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/Eth2TopicHandler.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/Eth2TopicHandler.java @@ -50,12 +50,12 @@ public class Eth2TopicHandler implements TopicHandler private final OperationProcessor processor; private final GossipEncoding gossipEncoding; private final Bytes4 forkDigest; - private final String topicName; private final SszSchema messageType; private final Eth2PreparedGossipMessageFactory preparedGossipMessageFactory; private final OperationMilestoneValidator forkValidator; private final NetworkingSpecConfig networkingConfig; private final DebugDataDumper debugDataDumper; + private final String topic; public Eth2TopicHandler( final RecentChainData recentChainData, @@ -72,7 +72,6 @@ public Eth2TopicHandler( this.processor = processor; this.gossipEncoding = gossipEncoding; this.forkDigest = forkDigest; - this.topicName = topicName; this.messageType = messageType; this.forkValidator = forkValidator; this.networkingConfig = networkingConfig; @@ -80,6 +79,7 @@ public Eth2TopicHandler( gossipEncoding.createPreparedGossipMessageFactory( recentChainData::getMilestoneByForkDigest); this.debugDataDumper = debugDataDumper; + this.topic = GossipTopics.getTopic(forkDigest, topicName, gossipEncoding); } public Eth2TopicHandler( @@ -159,10 +159,6 @@ private void processMessage( } } - private String getTopicName() { - return topicName; - } - private SszSchema getMessageType() { return messageType; } @@ -214,7 +210,7 @@ public OperationProcessor getProcessor() { } public String getTopic() { - return GossipTopics.getTopic(getForkDigest(), getTopicName(), getGossipEncoding()); + return topic; } public GossipEncoding getGossipEncoding() {