swarm/storage: Store chunk size

This commit is contained in:
Balint Gabor 2018-01-15 18:25:59 +01:00
parent 61f5aa4e01
commit 91b6a66f03
2 changed files with 3 additions and 0 deletions

View file

@ -17,6 +17,7 @@
package storage
import (
"encoding/binary"
"errors"
"fmt"
"io"
@ -211,6 +212,7 @@ func (self *dpaChunkStore) Get(key Key) (chunk *Chunk, err error) {
return nil, notFound
case <-chunk.ReqC:
}
chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8]))
return chunk, nil
}

View file

@ -59,6 +59,7 @@ func NewTestLocalStore(path string) (*LocalStore, error) {
// LocalStore is itself a chunk store
// unsafe, in that the data is not integrity checked
func (self *LocalStore) Put(chunk *Chunk) {
chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8]))
self.memStore.Put(chunk)
go func() {
self.DbStore.Put(chunk)