// Transaction wraps the given function in a transaction. In case the given
// functions returns an error, the transaction will be rolled back.
163843
func Transaction(f func(tx sqlx.Ext) error) error {
	tx, err := db.Beginx()
	if err != nil {
		return errors.Wrap(err, "storage: begin transaction error")
	}

	err = f(tx)
	if err != nil {
		if rbErr := tx.Rollback(); rbErr != nil {
			return errors.Wrap(rbErr, "storage: transaction rollback error")
		}
		return err
	}

	if err := tx.Commit(); err != nil {
		return errors.Wrap(err, "storage: transaction commit error")
	}
	return nil
}
348062
func (t *InjectedTransaction) Commit(ctx context.Context) error {
	t.cfg.RLock()
	defer t.cfg.RUnlock()
	if t.cfg.commitError != nil {
		return t.cfg.commitError
	}
	return t.Transaction.Commit(ctx)
}
584338
func (_ENSRegistry *ENSRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
	return _ENSRegistry.Contract.contract.Transact(opts, method, params...)
}
418133
func (c *Transactional) Rollback() revel.Result {
	if c.Txn != nil {
		if err := c.Txn.Rollback(); err != nil {
			if err != sql.ErrTxDone {
				panic(err)
			}
		}
		c.Txn = nil
	}
	return nil
}
17334
func (tc *TransCache) RollbackTransaction(transID string) {
	tc.transBufMux.Lock()
	delete(tc.transactionBuffer, transID)
	tc.transBufMux.Unlock()
}
803023
func (self *Bill) transaction(evt *Event) error {
	log.Infof("Event:BILL:transaction")
	result := &bills.BillOpts{}
	_ = result.FillStruct(evt.EventData.M) //we will manage error later
	for k, bp := range bills.BillProviders {
		if !self.skip(k) {
			err := bp.Transaction(result, self.M)
			if err != nil {
				return err
			}
		}
	}
	return nil
}
1017061
func (pgb *ChainDB) Transaction(txHash string) ([]*dbtypes.Tx, error) {
	ctx, cancel := context.WithTimeout(pgb.ctx, pgb.queryTimeout)
	defer cancel()
	_, dbTxs, err := RetrieveDbTxsByHash(ctx, pgb.db, txHash)
	return dbTxs, pgb.replaceCancelError(err)
}
864061
func RunInTransaction(db *sql.DB, f func(*sql.Tx) error) error {
	tx, err := db.Begin()
	if err != nil {
		return &TransactionError{nil, err}
	}
	err = f(tx)
	var txErr error
	if err == nil {
		txErr = tx.Commit()
	} else {
		txErr = tx.Rollback()
	}
	if err != nil || txErr != nil {
		return &TransactionError{err, txErr}
	}
	return nil
}
143150
func (_Chequebook *ChequebookRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
	return _Chequebook.Contract.ChequebookTransactor.contract.Transfer(opts)
}
654359
func (b *Backend) Transaction(ctx context.Context, txns []*physical.TxnEntry) error {
	// Quit early if we can
	if len(txns) == 0 {
		return nil
	}

	// Build all the ops before taking out the pool
	ms := make([]*spanner.Mutation, len(txns))
	for i, tx := range txns {
		op, key, value := tx.Operation, tx.Entry.Key, tx.Entry.Value

		switch op {
		case physical.DeleteOperation:
			ms[i] = spanner.Delete(b.table, spanner.Key{key})
		case physical.PutOperation:
			ms[i] = spanner.InsertOrUpdateMap(b.table, map[string]interface{}{
				"Key":   key,
				"Value": value,
			})
		default:
			return fmt.Errorf("unsupported transaction operation: %q", op)
		}
	}

	// Pooling
	b.permitPool.Acquire()
	defer b.permitPool.Release()

	// Transactivate!
	if _, err := b.client.Apply(ctx, ms); err != nil {
		return errwrap.Wrapf("failed to commit transaction: {{err}}", err)
	}

	return nil
}
555409
func (db *database) RunTransaction(ops []txn.Op) error {
	runner, closer := db.TransactionRunner()
	defer closer()
	return runner.RunTransaction(&jujutxn.Transaction{Ops: ops})
}
309704
func (tx *transaction) Rollback() error {
	// Prevent rollbacks on managed transactions.
	if tx.managed {
		tx.close()
		panic("managed transaction rollback not allowed")
	}

	// Ensure transaction state is valid.
	if err := tx.checkClosed(); err != nil {
		return err
	}

	tx.close()
	return nil
}
312426
func (s *DB) Commit() *DB {
	var emptySQLTx *sql.Tx
	if db, ok := s.db.(sqlTx); ok && db != nil && db != emptySQLTx {
		s.AddError(db.Commit())
	} else {
		s.AddError(ErrInvalidTransaction)
	}
	return s
}
47324
func (tx *Tx) OnCommit(fn func()) {
	tx.commitHandlers = append(tx.commitHandlers, fn)
}
1100717
func (c *BoundContract) Transact(opts *TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
	// Otherwise pack up the parameters and invoke the contract
	input, err := c.abi.Pack(method, params...)
	if err != nil {
		return nil, err
	}
	return c.transact(opts, &c.address, input)
}
879643
func (t *Transaction) Commit() ([]*Reply, error) {
	if t.conn.state != connStateConnected {
		return nil, ErrNotConnected
	}
	t.commands = append(t.commands, NewCommand("EXEC"))
	if t.conn.RequestTimeout != 0 {
		t.conn.tcpConn.SetWriteDeadline(time.Now().Add(t.conn.RequestTimeout * time.Duration(len(t.commands)/10+1)))
	}
	for _, cmd := range t.commands {
		err := cmd.writeCommand(t.conn)
		if err != nil {
			t.conn.fail()
			return nil, ErrWrite
		}
	}
	err := t.conn.wb.Flush()
	if err != nil {
		t.conn.fail()
		return nil, ErrWrite
	}
	if t.conn.RequestTimeout != 0 {
		t.conn.tcpConn.SetReadDeadline(time.Now().Add(t.conn.RequestTimeout * time.Duration(len(t.commands)/10+1)))
	}
	replies := make([]*Reply, len(t.commands))
	for i := range replies {
		rep, err := readReply(t.conn)
		if err != nil {
			t.conn.fail()
			return nil, err
		}
		replies[i] = rep
	}
	execReply := replies[len(replies)-1]
	if execReply.IsError() {
		return replies, ErrTransactionAborted
	}
	if execReply.IsNil() {
		return replies, ErrKeyChanged
	}
	if !execReply.IsArray() {
		t.conn.fail()
		return replies, ErrType
	}
	return execReply.Array()
}
474914
func (_ENS *ENSRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
	return _ENS.Contract.ENSTransactor.contract.Transact(opts, method, params...)
}