From 0ebef4a55eacf1c414fbfa5ff47e1790268616af Mon Sep 17 00:00:00 2001 From: ramin Date: Thu, 4 Jan 2024 13:56:05 +0000 Subject: [PATCH] ugly but catches them all --- verifier/writer.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/verifier/writer.go b/verifier/writer.go index 1db6e60..f9623d7 100644 --- a/verifier/writer.go +++ b/verifier/writer.go @@ -41,7 +41,9 @@ func (v *Verifier) AwaitBlock(ctx context.Context) <-chan *header.ExtendedHeader heights, err := v.rpc.Header.Subscribe(ctx) if err != nil { v.errCh <- err - v.Metrics.Errors.Add(ctx, 1) + if v.Metrics != nil { + v.Metrics.Errors.Add(ctx, 1) + } panic(err) } @@ -55,7 +57,9 @@ func (v *Verifier) WriteToBlock(ctx context.Context, height uint64) uint64 { writeBlob, err := generator.NewBlob() if err != nil { v.errCh <- err - v.Metrics.Errors.Add(ctx, 1) + if v.Metrics != nil { + v.Metrics.Errors.Add(ctx, 1) + } } writeHeight, err := v.rpc.Blob.Submit(ctx, []*blob.Blob{writeBlob}, nil) @@ -63,11 +67,17 @@ func (v *Verifier) WriteToBlock(ctx context.Context, height uint64) uint64 { v.errCh <- err logrus.Info(err) logrus.Error("failed to wrote blob to block ", writeHeight) - v.Metrics.Errors.Add(ctx, 1) + + if v.Metrics != nil { + v.Metrics.Errors.Add(ctx, 1) + } return writeHeight } - v.Metrics.Writes.Add(context.Background(), 1) + if v.Metrics != nil { + v.Metrics.Writes.Add(context.Background(), 1) + } + logrus.Info("wrote blob to block ", writeHeight) v.History.Logs[fmt.Sprintf("%v", writeHeight)] = DataLog{