Skip to content

Commit

Permalink
Merge branch 'master' into rp/populate-shares
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jul 4, 2023
2 parents 7b9b799 + ed26fa9 commit 4ecdaac
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
// Size of each share, in bytes
bufferSize := 64
// Init new codec
codec := rsmt2d.NewLeoRSFF8Codec()
codec := rsmt2d.NewLeoRSCodec()

ones := bytes.Repeat([]byte{1}, bufferSize)
twos := bytes.Repeat([]byte{2}, bufferSize)
Expand Down
9 changes: 0 additions & 9 deletions datasquare.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,6 @@ func (ds *dataSquare) SetCell(x uint, y uint, newChunk []byte) error {
return nil
}

// setCell overwrites the contents of a specific cell. setCell does not perform
// any input validation so most usecases should use `SetCell` instead of
// `setCell`. This method exists strictly for testing.
func (ds *dataSquare) setCell(x uint, y uint, newChunk []byte) {
ds.squareRow[x][y] = newChunk
ds.squareCol[y][x] = newChunk
ds.resetRoots()
}

// Flattened returns the concatenated rows of the data square.
func (ds *dataSquare) Flattened() [][]byte {
flattened := [][]byte(nil)
Expand Down
9 changes: 9 additions & 0 deletions datasquare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,12 @@ func (d *errorTree) Push(data []byte) error {
func (d *errorTree) Root() ([]byte, error) {
return nil, fmt.Errorf("error")
}

// setCell overwrites the contents of a specific cell. setCell does not perform
// any input validation so most use cases should use `SetCell` instead of
// `setCell`. This method exists strictly for testing.
func (ds *dataSquare) setCell(x uint, y uint, newChunk []byte) {
ds.squareRow[x][y] = newChunk
ds.squareCol[y][x] = newChunk
ds.resetRoots()
}
17 changes: 12 additions & 5 deletions extendeddatacrossword.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ var ErrUnrepairableDataSquare = errors.New("failed to solve data square")
// expected row or column Merkle root. It is also returned when the parity data
// from a row or a column is not equal to the encoded original data.
type ErrByzantineData struct {
Axis Axis // Axis of the data.
Index uint // Row/Col index.
Shares [][]byte // Pre-repaired shares. Missing shares are nil.
// Axis describes if this ErrByzantineData is for a row or column.
Axis Axis
// Index is the row or column index.
Index uint
// Shares contain the shares in the row or column that the client can
// determine proofs for (either through sampling or using shares decoded
// from the extended data square). In other words, it contains shares whose
// individual inclusion is guaranteed to be provable by the full node (i.e.
// shares usable in a bad encoding fraud proof). Missing shares are nil.
Shares [][]byte
}

func (e *ErrByzantineData) Error() string {
Expand Down Expand Up @@ -175,7 +182,7 @@ func (eds *ExtendedDataSquare) solveCrosswordRow(

// Insert rebuilt shares into square.
for c, s := range rebuiltShares {
eds.setCell(uint(r), uint(c), s)
eds.SetCell(uint(r), uint(c), s)
}

return true, true, nil
Expand Down Expand Up @@ -243,7 +250,7 @@ func (eds *ExtendedDataSquare) solveCrosswordCol(

// Insert rebuilt shares into square.
for r, s := range rebuiltShares {
eds.setCell(uint(r), uint(c), s)
eds.SetCell(uint(r), uint(c), s)
}

return true, true, nil
Expand Down

0 comments on commit 4ecdaac

Please sign in to comment.