-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix : fix compute hash #9
Conversation
README.md
Outdated
|
||
1. erasure package support RSEncoder which contain basic Encode and Decode reedSolomon APIs | ||
(1) erasure package support RSEncoder which contain basic Encode and Decode reedSolomon APIs | ||
``` | ||
RSEncoderStorage, err := NewRSEncoder(dataShards, parityShards, int64(blockSize)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.int64(blocksize) -> blocksize
2.Explain the meaning of blocksize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
README.md
Outdated
// decodes the input erasure encoded data shards data. | ||
func (r *RSEncoder) DecodeDataShards(content [][]byte) error { | ||
func (r *RSEncoder) DecodeDataShards(content [][]byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReconstructData or RecoverData seems clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DecodeDataShards and DecodeShards is corresponding to EncodeShards.
I added some clarifications to explain the function
@@ -22,7 +22,7 @@ func EncodeRawSegment(content []byte, dataShards, parityShards int) ([][]byte, e | |||
func DecodeRawSegment(pieceData [][]byte, segmentSize int64, dataShards, parityShards int) ([]byte, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.What's the difference between segmentSize and blockSize?
2.piceceData->shardDataList maybe a good choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No difference, These two interfaces are applied on the SP side as the segments is called in gnfd side, so the naming is closer to the application layer
README.md
Outdated
@@ -22,7 +22,7 @@ func EncodeRawSegment(content []byte, dataShards, parityShards int) ([][]byte, e | |||
func DecodeRawSegment(pieceData [][]byte, segmentSize int64, dataShards, parityShards int) ([]byte, error) | |||
``` | |||
|
|||
### Compute sha256 hash of file content | |||
### 2. Compute sha256 hash of file content | |||
|
|||
hash package support methods to compute hash roots of greenfield objects , the computed methods is based on | |||
redundancy Strategy of greenfield |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strategy-> strategy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
go/hash/hash.go
Outdated
@@ -32,51 +36,44 @@ func ComputerHash(reader io.Reader, segmentSize int64, dataShards, parityShards | |||
} | |||
if n > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe n != segmentSize and err == nil, need retry read from io.reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the API description below , the n may be less than segmentSize (end-of-file condition) , so if the err happen, just return an error. If end-of-file condition, the n just need to be less than segmentSize .
// When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read
changed to condition to " if n > 0 && n <= int(segmentSize)"
go/hash/hash_test.go
Outdated
for _, hash := range hashResult { | ||
if len(hash) != 64 { | ||
if len(hash) != 32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -86,7 +83,7 @@ func ComputerHash(reader io.Reader, segmentSize int64, dataShards, parityShards | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why result = append(result, hashList[i]) ?directly return hashList?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, some adjustments have been made, the result variable is no longer needed
go/hash/hash.go
Outdated
) | ||
|
||
// ComputerHash split the reader into segment, ec encode the data, compute the hash roots of pieces | ||
// return the hash result array list and data size | ||
func ComputerHash(reader io.Reader, segmentSize int64, dataShards, parityShards int) ([]string, int64, error) { | ||
func ComputerHash(reader io.Reader, segmentSize int64, dataShards, parityShards int) ([][]byte, int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CompluterHash's Computer
is a noun, which seems inappropriate function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to ComputeIntegrityHash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
fix bugs of computing hash root