code: func (s *GlobalStore) Export(w io.Writer) (n int, err error) {
  	s.mu.RLock()
  	defer s.mu.RUnlock()
  
  	tw := tar.NewWriter(w)
  	defer tw.Close()
  
  	buf := bytes.NewBuffer(make([]byte, 0, 1024))
  	encoder := json.NewEncoder(buf)
  	for key, addrs := range s.keyNodes {
  		buf.Reset()
  		if err = encoder.Encode(mock.ExportedChunk{
  			Addrs: addrs,
  			Data:  s.data[key],
  		}); err != nil {
  			return n, err
  		}
  
  		data := buf.Bytes()
  		hdr := &tar.Header{
  			Name: common.Bytes2Hex([]byte(key)),
  			Mode: 0644,
  			Size: int64(len(data)),
  		}
  		if err := tw.WriteHeader(hdr); err != nil {
  			return n, err
  		}
  		if _, err := tw.Write(data); err != nil {
  			return n, err
  		}
  		n++
  	}
  	return n, err
  }
docs: // Export writes to a writer a tar archive with all chunk data from
  // the store. It returns the number of chunks exported and an error.