Skip to content

Commit

Permalink
don't return nil, instead do empty batch
Browse files Browse the repository at this point in the history
  • Loading branch information
gupadhyaya committed Aug 19, 2024
1 parent 4a32f0b commit a1bcd13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
3 changes: 0 additions & 3 deletions proxy/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
9 changes: 3 additions & 6 deletions test/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a1bcd13

Please sign in to comment.