Skip to content

Commit

Permalink
avoid memoization
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Oct 24, 2024
1 parent 9b653ad commit 30cee21
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

import static tech.pegasys.teku.infrastructure.logging.P2PLogger.P2P_LOG;

import com.google.common.base.Suppliers;
import io.libp2p.core.pubsub.ValidationResult;
import java.util.Optional;
import java.util.concurrent.RejectedExecutionException;
import java.util.function.Supplier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -58,7 +56,7 @@ public class Eth2TopicHandler<MessageT extends SszData> implements TopicHandler
private final OperationMilestoneValidator<MessageT> forkValidator;
private final NetworkingSpecConfig networkingConfig;
private final DebugDataDumper debugDataDumper;
private final Supplier<String> topicCache;
private final String topic;

public Eth2TopicHandler(
final RecentChainData recentChainData,
Expand All @@ -83,9 +81,7 @@ public Eth2TopicHandler(
gossipEncoding.createPreparedGossipMessageFactory(
recentChainData::getMilestoneByForkDigest);
this.debugDataDumper = debugDataDumper;
this.topicCache =
Suppliers.memoize(
() -> GossipTopics.getTopic(getForkDigest(), getTopicName(), getGossipEncoding()));
this.topic = GossipTopics.getTopic(forkDigest, topicName, gossipEncoding);
}

public Eth2TopicHandler(
Expand Down Expand Up @@ -220,7 +216,7 @@ public OperationProcessor<MessageT> getProcessor() {
}

public String getTopic() {
return topicCache.get();
return topic;
}

public GossipEncoding getGossipEncoding() {
Expand Down

0 comments on commit 30cee21

Please sign in to comment.