code: func ImportPreimages(db ethdb.Database, fn string) error {
  	log.Info("Importing preimages", "file", fn)
  
  	// Open the file handle and potentially unwrap the gzip stream
  	fh, err := os.Open(fn)
  	if err != nil {
  		return err
  	}
  	defer fh.Close()
  
  	var reader io.Reader = fh
  	if strings.HasSuffix(fn, ".gz") {
  		if reader, err = gzip.NewReader(reader); err != nil {
  			return err
  		}
  	}
  	stream := rlp.NewStream(reader, 0)
  
  	// Import the preimages in batches to prevent disk trashing
  	preimages := make(map[common.Hash][]byte)
  
  	for {
  		// Read the next entry and ensure it's not junk
  		var blob []byte
  
  		if err := stream.Decode(&blob); err != nil {
  			if err == io.EOF {
  				break
  			}
  			return err
  		}
  		// Accumulate the preimages and flush when enough ws gathered
  		preimages[crypto.Keccak256Hash(blob)] = common.CopyBytes(blob)
  		if len(preimages) > 1024 {
  			rawdb.WritePreimages(db, preimages)
  			preimages = make(map[common.Hash][]byte)
  		}
  	}
  	// Flush the last batch preimage data
  	if len(preimages) > 0 {
  		rawdb.WritePreimages(db, preimages)
  	}
  	return nil
  }
docs: // ImportPreimages imports a batch of exported hash preimages into the database.