[#235] services/object: Implement new GetRange algorithm

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-07 20:49:47 +03:00 committed by Alex Vanin
parent 91d8e0a4de
commit 1d23483828
37 changed files with 703 additions and 1125 deletions

View file

@ -20,7 +20,7 @@ type onceHashWriter struct {
}
type hasher interface {
add([]byte)
WriteChunk([]byte) error
sum() ([]byte, error)
}
@ -36,8 +36,10 @@ type singleHasher struct {
hash []byte
}
func (h *singleHasher) add(p []byte) {
func (h *singleHasher) WriteChunk(p []byte) error {
h.hash = p
return nil
}
func (h *singleHasher) sum() ([]byte, error) {
@ -52,18 +54,20 @@ func (w *onceHashWriter) write(hs [][]byte) {
})
}
func (h *tzHasher) add(p []byte) {
func (h *tzHasher) WriteChunk(p []byte) error {
h.hashes = append(h.hashes, p)
return
return nil
}
func (h *tzHasher) sum() ([]byte, error) {
return tz.Concat(h.hashes)
}
func (h *commonHasher) add(p []byte) {
func (h *commonHasher) WriteChunk(p []byte) error {
h.h.Write(p)
return nil
}
func (h *commonHasher) sum() ([]byte, error) {