code: func (tx *transaction) FetchBlock(hash *chainhash.Hash) ([]byte, error) {
  	// Ensure transaction state is valid.
  	if err := tx.checkClosed(); err != nil {
  		return nil, err
  	}
  
  	// When the block is pending to be written on commit return the bytes
  	// from there.
  	if idx, exists := tx.pendingBlocks[*hash]; exists {
  		return tx.pendingBlockData[idx].bytes, nil
  	}
  
  	// Lookup the location of the block in the files from the block index.
  	blockRow, err := tx.fetchBlockRow(hash)
  	if err != nil {
  		return nil, err
  	}
  	location := deserializeBlockLoc(blockRow)
  
  	// Read the block from the appropriate location.  The function also
  	// performs a checksum over the data to detect data corruption.
  	blockBytes, err := tx.db.store.readBlock(hash, location)
  	if err != nil {
  		return nil, err
  	}
  
  	return blockBytes, nil
  }
docs: // FetchBlock returns the raw serialized bytes for the block identified by the
  // given hash.  The raw bytes are in the format returned by Serialize on a
  // wire.MsgBlock.
  //
  // Returns the following errors as required by the interface contract:
  //   - ErrBlockNotFound if the requested block hash does not exist
  //   - ErrTxClosed if the transaction has already been closed
  //   - ErrCorruption if the database has somehow become corrupted
  //
  // In addition, returns ErrDriverSpecific if any failures occur when reading the
  // block files.
  //
  // NOTE: The data returned by this function is only valid during a database
  // transaction.  Attempting to access it after a transaction has ended results
  // in undefined behavior.  This constraint prevents additional data copies and
  // allows support for memory-mapped database implementations.
  //
  // This function is part of the database.Tx interface implementation.