Skip to content

Commit

Permalink
make batch pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
gupadhyaya committed Aug 2, 2024
1 parent c195453 commit ab3fd35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions proxy/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ func (c *Client) SubmitRollupTransaction(ctx context.Context, rollupId []byte, t
}

// GetNextBatch returns the next batch of transactions from sequencer to rollup.
func (c *Client) GetNextBatch(ctx context.Context, lastBatch sequencing.Batch) (sequencing.Batch, error) {
func (c *Client) GetNextBatch(ctx context.Context, lastBatch *sequencing.Batch) (*sequencing.Batch, error) {
resp, err := c.SequencerOutputClient.GetNextBatch(ctx, lastBatch.ToProto())
if err != nil {
return sequencing.Batch{}, err
return nil, err
}
b := sequencing.Batch{}
b := &sequencing.Batch{}
b.FromProto(resp)
return b, nil
}

// VerifyBatch verifies a batch of transactions received from the sequencer.
func (c *Client) VerifyBatch(ctx context.Context, batch sequencing.Batch) (bool, error) {
func (c *Client) VerifyBatch(ctx context.Context, batch *sequencing.Batch) (bool, error) {
resp, err := c.BatchVerifierClient.VerifyBatch(ctx, batch.ToProto())
if err != nil {
return false, err
Expand Down
4 changes: 2 additions & 2 deletions proxy/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *proxyInputSrv) SubmitRollupTransaction(ctx context.Context, req *pbseq.

// GetNextBatch returns the next batch of transactions from sequencer to rollup.
func (s *proxyOutputSrv) GetNextBatch(ctx context.Context, req *pbseq.Batch) (*pbseq.Batch, error) {
lastBatch := sequencing.Batch{}
lastBatch := &sequencing.Batch{}
lastBatch.FromProto(req)
batch, err := s.SequencerOutput.GetNextBatch(ctx, lastBatch)
if err != nil {
Expand All @@ -64,7 +64,7 @@ func (s *proxyOutputSrv) GetNextBatch(ctx context.Context, req *pbseq.Batch) (*p

// VerifyBatch verifies a batch of transactions received from the sequencer.
func (s *proxyVerificationSrv) VerifyBatch(ctx context.Context, req *pbseq.Batch) (*pbseq.VerificationResponse, error) {
batch := sequencing.Batch{}
batch := &sequencing.Batch{}
batch.FromProto(req)
ok, err := s.BatchVerifier.VerifyBatch(ctx, batch)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions test/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ func (d *DummySequencer) SubmitRollupTransaction(ctx context.Context, rollupId [
}

// GetNextBatch implements sequencing.Sequencer.
func (d *DummySequencer) GetNextBatch(ctx context.Context, lastBatch sequencing.Batch) (sequencing.Batch, error) {
func (d *DummySequencer) GetNextBatch(ctx context.Context, lastBatch *sequencing.Batch) (*sequencing.Batch, error) {
batch := d.tq.GetNextBatch()
batchBytes, err := batch.Marshal()
if err != nil {
return sequencing.Batch{}, err
return nil, err
}
d.lastBatchHash = hashSHA256(batchBytes)
d.seenBatches[string(d.lastBatchHash)] = struct{}{}
return batch, nil
return &batch, nil
}

// VerifyBatch implements sequencing.Sequencer.
func (d *DummySequencer) VerifyBatch(ctx context.Context, batch sequencing.Batch) (bool, error) {
func (d *DummySequencer) VerifyBatch(ctx context.Context, batch *sequencing.Batch) (bool, error) {
batchBytes, err := batch.Marshal()
if err != nil {
return false, err
Expand Down

0 comments on commit ab3fd35

Please sign in to comment.