Compare commits

..

1 Commits

Author SHA1 Message Date
James Mills
e9c858d43f Add CRC Checksum checks on reading values back 2019-03-16 12:16:23 +10:00

View File

@@ -2,6 +2,7 @@ package bitcask
import (
"fmt"
"hash/crc32"
"io"
"io/ioutil"
"os"
@@ -61,6 +62,11 @@ func (b *Bitcask) Get(key string) ([]byte, error) {
return nil, err
}
crc := crc32.ChecksumIEEE(e.Value)
if crc != e.CRC {
return nil, fmt.Errorf("error: crc checksum falied %s %d != %d", key, e.CRC, crc)
}
return e.Value, nil
}