Skip to content

Commit

Permalink
Do not save to file if p2p warnings are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 10, 2024
1 parent f6652af commit 882f3ae
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.infrastructure.logging.LoggingConfigurator;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;

public class P2PDumpManager {
Expand All @@ -29,6 +30,8 @@ public class P2PDumpManager {
private static final String GOSSIP_REJECTED_DIR = "rejected_gossip_messages";
private static final String INVALID_BLOCK_DIR = "invalid_blocks";

private final boolean isIncludeP2pWarnings = LoggingConfigurator.isIncludeP2pWarnings();

private final Path directory;

public P2PDumpManager(final Path directory) {
Expand All @@ -54,6 +57,9 @@ public P2PDumpManager(final Path directory) {

public String saveGossipMessageDecodingError(
final String topic, final String arrivalTimestamp, final Bytes originalMessage) {
if (isIncludeP2pWarnings) {
return "";
}
final String fileName = String.format("%s_%s.ssz", arrivalTimestamp, topic);
final String identifiers = String.format("Topic: %s", topic);
return saveBytesToFile(
Expand All @@ -66,6 +72,9 @@ public String saveGossipMessageDecodingError(

public String saveGossipRejectedMessageToFile(
final String topic, final String arrivalTimestamp, final Bytes decodedMessage) {
if (isIncludeP2pWarnings) {
return "";
}
final String fileName = String.format("%s_%s.ssz", arrivalTimestamp, topic);
final String identifiers = String.format("Topic: %s", topic);
return saveBytesToFile(
Expand All @@ -74,6 +83,9 @@ public String saveGossipRejectedMessageToFile(

public String saveInvalidBlockToFile(
final UInt64 slot, final Bytes32 blockRoot, final Bytes blockSsz) {
if (isIncludeP2pWarnings) {
return "";
}
final String fileName =
String.format("slot%s_root%s.ssz", slot, blockRoot.toUnprefixedHexString());
final String identifiers = String.format("Slot: %s, Block Root: %s", slot, blockRoot);
Expand Down

0 comments on commit 882f3ae

Please sign in to comment.