Skip to content

Commit

Permalink
fix(ipld): always commit requested/repaired data on disk on retrieve
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Apr 26, 2022
1 parent bd8cb4e commit 9d786ac
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ipld/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ func (r *Retriever) newSession(ctx context.Context, dah *da.DataAvailabilityHead
}

func (rs *retrieverSession) retrieve(ctx context.Context, q *quadrant) (*rsmt2d.ExtendedDataSquare, error) {
defer func() {
// all shares which were requested or repaired are written to disk with the commit
// we store *all*, so they are served to the network, including incorrectly committed data(BEFP case),
// so that network can check BEFP
if err := rs.adder.Commit(); err != nil {
log.Errorw("committing DAG", "err", err)
}
}()
// request and fill quadrant's into
// we don't care about the errors here, just need to request as much data as we can to be able to reconstruct below
rs.request(ctx, q)
Expand All @@ -125,11 +133,6 @@ func (rs *retrieverSession) retrieve(ctx context.Context, q *quadrant) (*rsmt2d.
return nil, format.ErrNotFound
}

err = rs.adder.Commit()
if err != nil {
return nil, err
}

return rsmt2d.ImportExtendedDataSquare(rs.square, rs.codec, rs.treeFn)
}

Expand Down

0 comments on commit 9d786ac

Please sign in to comment.