From a1bcd1322d890d8d319b8c482c9482188ad302be Mon Sep 17 00:00:00 2001 From: gupadhyaya Date: Mon, 19 Aug 2024 11:27:57 +0400 Subject: [PATCH] don't return nil, instead do empty batch --- proxy/grpc/server.go | 3 --- test/dummy.go | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/proxy/grpc/server.go b/proxy/grpc/server.go index 7be1747..18af360 100644 --- a/proxy/grpc/server.go +++ b/proxy/grpc/server.go @@ -59,9 +59,6 @@ func (s *proxyOutputSrv) GetNextBatch(ctx context.Context, req *pbseq.Batch) (*p if err != nil { return nil, err } - if batch == nil { - return nil, nil - } return batch.ToProto(), nil } diff --git a/test/dummy.go b/test/dummy.go index 335cfb1..276f736 100644 --- a/test/dummy.go +++ b/test/dummy.go @@ -39,10 +39,6 @@ func (tq *TransactionQueue) GetNextBatch() *sequencing.Batch { defer tq.mu.Unlock() size := len(tq.queue) - if size == 0 { - return nil - } - batch := tq.queue[:size] tq.queue = tq.queue[size:] return &sequencing.Batch{Transactions: batch} @@ -90,8 +86,9 @@ func (d *DummySequencer) GetNextBatch(ctx context.Context, lastBatch *sequencing } batch := d.tq.GetNextBatch() - if batch == nil { - return nil, nil + // If there are no transactions, return empty batch without updating the last batch hash + if batch.Transactions == nil { + return batch, nil } batchBytes, err := batch.Marshal()