@@ -312,7 +312,7 @@ func decodeIndex(data []byte, index *dpaDBIndex) error {
312312 return dec .Decode (index )
313313}
314314
315- func decodeData (addr Address , data []byte ) (* chunk , error ) {
315+ func decodeData (addr Address , data []byte ) (Chunk , error ) {
316316 return NewChunk (addr , data [32 :]), nil
317317}
318318
@@ -502,7 +502,7 @@ func (s *LDBStore) Import(in io.Reader) (int64, error) {
502502}
503503
504504// Cleanup iterates over the database and deletes chunks if they pass the `f` condition
505- func (s * LDBStore ) Cleanup (f func (* chunk ) bool ) {
505+ func (s * LDBStore ) Cleanup (f func (Chunk ) bool ) {
506506 var errorsFound , removed , total int
507507
508508 it := s .db .NewIterator ()
@@ -551,12 +551,14 @@ func (s *LDBStore) Cleanup(f func(*chunk) bool) {
551551 continue
552552 }
553553
554- cs := int64 (binary .LittleEndian .Uint64 (c .sdata [:8 ]))
555- log .Trace ("chunk" , "key" , fmt .Sprintf ("%x" , key ), "ck" , fmt .Sprintf ("%x" , ck ), "dkey" , fmt .Sprintf ("%x" , datakey ), "dataidx" , index .Idx , "po" , po , "len data" , len (data ), "len sdata" , len (c .sdata ), "size" , cs )
554+ sdata := c .Data ()
555+
556+ cs := int64 (binary .LittleEndian .Uint64 (sdata [:8 ]))
557+ log .Trace ("chunk" , "key" , fmt .Sprintf ("%x" , key ), "ck" , fmt .Sprintf ("%x" , ck ), "dkey" , fmt .Sprintf ("%x" , datakey ), "dataidx" , index .Idx , "po" , po , "len data" , len (data ), "len sdata" , len (sdata ), "size" , cs )
556558
557559 // if chunk is to be removed
558560 if f (c ) {
559- log .Warn ("chunk for cleanup" , "key" , fmt .Sprintf ("%x" , key ), "ck" , fmt .Sprintf ("%x" , ck ), "dkey" , fmt .Sprintf ("%x" , datakey ), "dataidx" , index .Idx , "po" , po , "len data" , len (data ), "len sdata" , len (c . sdata ), "size" , cs )
561+ log .Warn ("chunk for cleanup" , "key" , fmt .Sprintf ("%x" , key ), "ck" , fmt .Sprintf ("%x" , ck ), "dkey" , fmt .Sprintf ("%x" , datakey ), "dataidx" , index .Idx , "po" , po , "len data" , len (data ), "len sdata" , len (sdata ), "size" , cs )
560562 s .deleteNow (& index , getIndexKey (key [1 :]), po )
561563 removed ++
562564 errorsFound ++
@@ -980,7 +982,7 @@ func (s *LDBStore) Has(_ context.Context, addr Address) bool {
980982}
981983
982984// TODO: To conform with other private methods of this object indices should not be updated
983- func (s * LDBStore ) get (addr Address ) (chunk * chunk , err error ) {
985+ func (s * LDBStore ) get (addr Address ) (chunk Chunk , err error ) {
984986 if s .closed {
985987 return nil , ErrDBClosed
986988 }
0 commit comments