Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Apr 5, 2024
1 parent 3e1c15b commit 00193d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions arbstate/daprovider/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type BlobReader interface {
Initialize(ctx context.Context) error
}

// PreimageRecorder is used to add (key,value) pair to the map accessed by key = ty of a bigger map, preimages.
// If ty doesn't exist as a key in the preimages map, then it is intialized to map[common.Hash][]byte and then (key,value) pair is added
type PreimageRecorder func(key common.Hash, value []byte, ty arbutil.PreimageType)

// RecordPreimagesTo takes in preimages map and returns a function that can be used
Expand Down
2 changes: 1 addition & 1 deletion arbstate/daprovider/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type writerForDAS struct {
}

func (d *writerForDAS) Store(ctx context.Context, message []byte, timeout uint64, sig []byte, disableFallbackStoreDataOnChain bool) ([]byte, error) {
cert, err := d.dasWriter.Store(ctx, message, timeout, []byte{}) // b.daWriter will append signature if enabled
cert, err := d.dasWriter.Store(ctx, message, timeout, []byte{})
if errors.Is(err, ErrBatchToDasFailed) {
if disableFallbackStoreDataOnChain {
return nil, errors.New("unable to batch to DAS and fallback storing data on chain is disabled")
Expand Down
4 changes: 2 additions & 2 deletions staker/stateless_block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e *
foundDA := false
for _, dapReader := range v.dapReaders {
if dapReader != nil && dapReader.IsValidHeaderByte(batch.Data[40]) {
recorder := daprovider.RecordPreimagesTo(e.Preimages)
_, err := dapReader.RecoverPayloadFromBatch(ctx, batch.Number, batch.BlockHash, batch.Data, recorder, true)
preimageRecorder := daprovider.RecordPreimagesTo(e.Preimages)
_, err := dapReader.RecoverPayloadFromBatch(ctx, batch.Number, batch.BlockHash, batch.Data, preimageRecorder, true)
if err != nil {
// Matches the way keyset validation was done inside DAS readers i.e logging the error
// But other daproviders might just want to return the error
Expand Down

0 comments on commit 00193d0

Please sign in to comment.