code: func updateCRLShard(c context.Context, cn string, shard shards.Shard, count, idx int) error {
  	blob := shard.Serialize()
  	hash := sha1.Sum(blob)
  	digest := hex.EncodeToString(hash[:])
  
  	// Have it already?
  	header := CRLShardHeader{ID: shardEntityID(cn, count, idx)}
  	switch err := ds.Get(c, &header); {
  	case err != nil && err != ds.ErrNoSuchEntity:
  		return err
  	case err == nil && header.SHA1 == digest:
  		logging.Infof(c, "CRL for %q: shard %d/%d is up-to-date", cn, idx, count)
  		return nil
  	}
  
  	// Zip before uploading.
  	zipped, err := utils.ZlibCompress(blob)
  	if err != nil {
  		return err
  	}
  	logging.Infof(
  		c, "CRL for %q: shard %d/%d updated (%d bytes zipped, %d%% compression)",
  		cn, idx, count, len(zipped), 100*len(zipped)/len(blob))
  
  	// Upload, updating the header and the body at once.
  	return ds.RunInTransaction(c, func(c context.Context) error {
  		header.SHA1 = digest
  		body := CRLShardBody{
  			Parent:     ds.KeyForObj(c, &header),
  			SHA1:       digest,
  			ZippedData: zipped,
  		}
  		return ds.Put(c, &header, &body)
  	}, nil)
  }
docs: // updateCRLShard updates entities that holds a single shard of a CRL set.