Skip to content

Commit

Permalink
Do not initialize log level to ensure each case is handled explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Feb 15, 2024
1 parent 68c6172 commit 4408a92
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/beacon-node/src/network/processor/gossipHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler
chain.seenGossipBlockInput.prune();
})
.catch((e) => {
// Any unexpected error
let logLevel = LogLevel.error;
// Adjust verbosity based on error type
let logLevel: LogLevel;

if (e instanceof BlockError) {
switch (e.type.code) {
Expand Down Expand Up @@ -287,6 +287,9 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler
// Misbehaving peer, user cannot be expected to do something about this
logLevel = LogLevel.warn;
}
} else {
// Any unexpected error
logLevel = LogLevel.error;
}
metrics?.gossipBlock.processBlockErrors.inc({error: e instanceof BlockError ? e.type.code : "NOT_BLOCK_ERROR"});
logger[logLevel]("Error receiving block", {slot: signedBlock.message.slot, peer: peerIdStr}, e as Error);
Expand Down

0 comments on commit 4408a92

Please sign in to comment.