Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Renamed hashhash to hashofhash

Signed-off-by: Alexander Wels <awels@redhat.com>
  • Loading branch information
awels committed Oct 9, 2024
1 parent 7fd9dd1 commit 04a9a6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/blockrsync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (b *BlockrsyncClient) ConnectToTarget() error {
b.sourceSize = size
b.log.V(5).Info("Hashed file", "filename", b.sourceFile, "size", size)
reader := snappy.NewReader(conn)
if match, err := b.hasher.CompareHashHash(conn); err != nil {
if match, err := b.hasher.CompareHashOfHash(conn); err != nil {
return err
} else if match {
b.log.Info("No differences found, exiting")
Expand Down
4 changes: 2 additions & 2 deletions pkg/blockrsync/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Hasher interface {
SerializeHashes(io.Writer) error
DeserializeHashes(io.Reader) (int64, map[int64][]byte, error)
BlockSize() int64
CompareHashHash(io.ReadWriter) (bool, error)
CompareHashOfHash(io.ReadWriter) (bool, error)
}

type OffsetHash struct {
Expand Down Expand Up @@ -306,7 +306,7 @@ func (f *FileHasher) DeserializeHashes(r io.Reader) (int64, map[int64][]byte, er
return blockSize, hashes, nil
}

func (f *FileHasher) CompareHashHash(rw io.ReadWriter) (bool, error) {
func (f *FileHasher) CompareHashOfHash(rw io.ReadWriter) (bool, error) {
f.log.V(5).Info("Comparing hash of hashes", "hash", base64.StdEncoding.EncodeToString(f.hashHash))
if n, err := rw.Write(f.hashHash); err != nil {
return false, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/blockrsync/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (b *BlockrsyncServer) StartServer() error {
defer conn.Close()
writer := snappy.NewBufferedWriter(conn)
<-readyChan
if match, err := b.hasher.CompareHashHash(conn); err != nil {
if match, err := b.hasher.CompareHashOfHash(conn); err != nil {
return err
} else if match {
b.log.Info("No differences found, exiting")
Expand Down

0 comments on commit 04a9a6d

Please sign in to comment.