Skip to content

Commit

Permalink
make tier2 service gracefully error out if fields are missing from th…
Browse files Browse the repository at this point in the history
…e request
  • Loading branch information
sduchesneau committed Apr 3, 2024
1 parent 09a888f commit 61260f0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions service/tier2.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ func (s *Tier2Service) ProcessRange(request *pbssinternal.ProcessRangeRequest, s

logger.Info("incoming substreams ProcessRange request", fields...)

switch {

case request.MeteringConfig == "":
return fmt.Errorf("metering config is required in request")
case request.BlockType == "":
return fmt.Errorf("block type is required in request")
case request.StateStore == "":
return fmt.Errorf("state store is required in request")
case request.MergedBlocksStore == "":
return fmt.Errorf("merged blocks store is required in request")
case request.StateBundleSize == 0:
return fmt.Errorf("a non-zero state bundle size is required in request")
}

emitter, err := dmetering.New(request.MeteringConfig, logger)
if err != nil {
return connect.NewError(connect.CodeInternal, fmt.Errorf("unable to initialize dmetering: %w", err))
Expand Down

0 comments on commit 61260f0

Please sign in to comment.