code: func (h *blockHeaderStore) WriteHeaders(hdrs ...BlockHeader) error {
  	// Lock store for write.
  	h.mtx.Lock()
  	defer h.mtx.Unlock()
  
  	// First, we'll grab a buffer from the write buffer pool so we an
  	// reduce our total number of allocations, and also write the headers
  	// in a single swoop.
  	headerBuf := headerBufPool.Get().(*bytes.Buffer)
  	headerBuf.Reset()
  	defer headerBufPool.Put(headerBuf)
  
  	// Next, we'll write out all the passed headers in series into the
  	// buffer we just extracted from the pool.
  	for _, header := range hdrs {
  		if err := header.Serialize(headerBuf); err != nil {
  			return err
  		}
  	}
  
  	// With all the headers written to the buffer, we'll now write out the
  	// entire batch in a single write call.
  	if err := h.appendRaw(headerBuf.Bytes()); err != nil {
  		return err
  	}
  
  	// Once those are written, we'll then collate all the headers into
  	// headerEntry instances so we can write them all into the index in a
  	// single atomic batch.
  	headerLocs := make([]headerEntry, len(hdrs))
  	for i, header := range hdrs {
  		headerLocs[i] = header.toIndexEntry()
  	}
  
  	return h.addHeaders(headerLocs)
  }
docs: // WriteHeaders writes a set of headers to disk and updates the index in a
  // single atomic transaction.
  //
  // NOTE: Part of the BlockHeaderStore interface.