code: func (c *dbCache) updateDB(fn func(ldbTx *leveldb.Transaction) error) error {
  	// Start a leveldb transaction.
  	ldbTx, err := c.ldb.OpenTransaction()
  	if err != nil {
  		return convertErr("failed to open ldb transaction", err)
  	}
  
  	if err := fn(ldbTx); err != nil {
  		ldbTx.Discard()
  		return err
  	}
  
  	// Commit the leveldb transaction and convert any errors as needed.
  	if err := ldbTx.Commit(); err != nil {
  		return convertErr("failed to commit leveldb transaction", err)
  	}
  	return nil
  }
docs: // updateDB invokes the passed function in the context of a managed leveldb
  // transaction.  Any errors returned from the user-supplied function will cause
  // the transaction to be rolled back and are returned from this function.
  // Otherwise, the transaction is committed when the user-supplied function
  // returns a nil error.