aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-03-06 14:24:24 -0800
committerChris Lu <chris.lu@gmail.com>2021-03-06 14:26:27 -0800
commit38fc200e564e1086742c3ef908b7793be942356a (patch)
treef000d56b50b4d7cdd46cbcf774eeeefe2df25179
parent1444e9d2758ab1f6adeb16a656c1c1cea4292145 (diff)
downloadseaweedfs-38fc200e564e1086742c3ef908b7793be942356a.tar.xz
seaweedfs-38fc200e564e1086742c3ef908b7793be942356a.zip
CRCWriter consistent with CRC
-rw-r--r--weed/storage/needle/crc.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/weed/storage/needle/crc.go b/weed/storage/needle/crc.go
index e1bac829a..22456faa2 100644
--- a/weed/storage/needle/crc.go
+++ b/weed/storage/needle/crc.go
@@ -2,7 +2,6 @@ package needle
import (
"fmt"
- "hash"
"io"
"github.com/klauspost/crc32"
@@ -35,21 +34,21 @@ func (n *Needle) Etag() string {
func NewCRCwriter(w io.Writer) *CRCwriter {
return &CRCwriter{
- h: crc32.New(table),
+ crc: CRC(0),
w: w,
}
}
type CRCwriter struct {
- h hash.Hash32
- w io.Writer
+ crc CRC
+ w io.Writer
}
func (c *CRCwriter) Write(p []byte) (n int, err error) {
n, err = c.w.Write(p) // with each write ...
- c.h.Write(p) // ... update the hash
+ c.crc = c.crc.Update(p)
return
}
-func (c *CRCwriter) Sum() uint32 { return c.h.Sum32() } // final hash
+func (c *CRCwriter) Sum() uint32 { return c.crc.Value() } // final hash