code: func (s *GlobalStore) Import(r io.Reader) (n int, err error) {
  	s.mu.Lock()
  	defer s.mu.Unlock()
  
  	tr := tar.NewReader(r)
  
  	for {
  		hdr, err := tr.Next()
  		if err != nil {
  			if err == io.EOF {
  				break
  			}
  			return n, err
  		}
  
  		data, err := ioutil.ReadAll(tr)
  		if err != nil {
  			return n, err
  		}
  
  		var c mock.ExportedChunk
  		if err = json.Unmarshal(data, &c); err != nil {
  			return n, err
  		}
  
  		key := common.Hex2Bytes(hdr.Name)
  		s.keyNodes[string(key)] = c.Addrs
  		for _, addr := range c.Addrs {
  			if i, has := s.nodeKeyIndex(addr, key); !has {
  				s.nodeKeys[addr] = append(s.nodeKeys[addr], nil)
  				copy(s.nodeKeys[addr][i+1:], s.nodeKeys[addr][i:])
  				s.nodeKeys[addr][i] = key
  			}
  			if i, found := s.nodeIndex(addr); !found {
  				s.nodes = append(s.nodes, addr)
  				copy(s.nodes[i+1:], s.nodes[i:])
  				s.nodes[i] = addr
  			}
  		}
  		if i, found := s.keyIndex(key); !found {
  			s.keys = append(s.keys, nil)
  			copy(s.keys[i+1:], s.keys[i:])
  			s.keys[i] = key
  		}
  		s.data[string(key)] = c.Data
  		n++
  	}
  	return n, err
  }
docs: // Import reads tar archive from a reader that contains exported chunk data.
  // It returns the number of chunks imported and an error.