code: func (s *LDBStore) Import(in io.Reader) (int64, error) {
  	tr := tar.NewReader(in)
  
  	ctx, cancel := context.WithCancel(context.Background())
  	defer cancel()
  
  	countC := make(chan int64)
  	errC := make(chan error)
  	var count int64
  	go func() {
  		for {
  			hdr, err := tr.Next()
  			if err == io.EOF {
  				break
  			} else if err != nil {
  				select {
  				case errC <- err:
  				case <-ctx.Done():
  				}
  			}
  
  			if len(hdr.Name) != 64 {
  				log.Warn("ignoring non-chunk file", "name", hdr.Name)
  				continue
  			}
  
  			keybytes, err := hex.DecodeString(hdr.Name)
  			if err != nil {
  				log.Warn("ignoring invalid chunk file", "name", hdr.Name, "err", err)
  				continue
  			}
  
  			data, err := ioutil.ReadAll(tr)
  			if err != nil {
  				select {
  				case errC <- err:
  				case <-ctx.Done():
  				}
  			}
  			key := Address(keybytes)
  			chunk := NewChunk(key, data[32:])
  
  			go func() {
  				select {
  				case errC <- s.Put(ctx, chunk):
  				case <-ctx.Done():
  				}
  			}()
  
  			count++
  		}
  		countC <- count
  	}()
  
  	// wait for all chunks to be stored
  	i := int64(0)
  	var total int64
  	for {
  		select {
  		case err := <-errC:
  			if err != nil {
  				return count, err
  			}
  			i++
  		case total = <-countC:
  		case <-ctx.Done():
  			return i, ctx.Err()
  		}
  		if total > 0 && i == total {
  			return total, nil
  		}
  	}
  }
docs: // of chunks read.