From 04a9a6d441239160de9a3571ca59cef1098f7e25 Mon Sep 17 00:00:00 2001 From: Alexander Wels Date: Wed, 9 Oct 2024 07:47:31 -0500 Subject: [PATCH] Address code review comments Renamed hashhash to hashofhash Signed-off-by: Alexander Wels --- pkg/blockrsync/client.go | 2 +- pkg/blockrsync/hasher.go | 4 ++-- pkg/blockrsync/server.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/blockrsync/client.go b/pkg/blockrsync/client.go index 90999b2..dc2218a 100644 --- a/pkg/blockrsync/client.go +++ b/pkg/blockrsync/client.go @@ -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") diff --git a/pkg/blockrsync/hasher.go b/pkg/blockrsync/hasher.go index a97e519..b9f8945 100644 --- a/pkg/blockrsync/hasher.go +++ b/pkg/blockrsync/hasher.go @@ -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 { @@ -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 diff --git a/pkg/blockrsync/server.go b/pkg/blockrsync/server.go index 7edfc92..83e2bf8 100644 --- a/pkg/blockrsync/server.go +++ b/pkg/blockrsync/server.go @@ -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")