// AdjustRewardBalanceOfAddresses adjusts the balance of the specified addresses by the specified amount
AdjustRewardBalanceOfAddresses adjusts the balance of the specified addresses by the specified amount
// AdjustRewardBalanceOfAddresses adjusts the balance of the specified addresses by the specified amount
func AdjustRewardBalanceOfAddresses(node sqalx.Node, addresses []string, amount decimal.Decimal) ([]*RewardBalance, error) {
	tx, err := node.Beginx()
	if err != nil {
		return nil, stacktrace.Propagate(err, "")
	}
	defer tx.Rollback()
	now := time.Now()
	builder := sdb.Insert("reward_balance").Columns("rewards_address", "balance", "updated_at")
	for _, address := range addresses {
		builder = builder.Values(address, amount, now)
	}
	query, args, err := builder.Suffix(`
		ON CONFLICT (rewards_address)
		DO UPDATE SET balance = reward_balance.balance + EXCLUDED.balance, updated_at = EXCLUDED.updated_at
		RETURNING rewards_address, balance, updated_at`).
		ToSql()
	logger.Println(query, args, err)
	balances := []*RewardBalance{}
	err = tx.Tx().Select(&balances, query, args...)
	if err != nil {
		return nil, stacktrace.Propagate(err, "")
	}
	return balances, stacktrace.Propagate(tx.Commit(), "")
}
func AdjustRewardBalanceOfAddresses ( node sqalx . Node , addresses [ ] string , amount decimal . Decimal ) ( [ ] * RewardBalance , error ) { tx , err := node . Beginx ( ) if err != nil { return nil , stacktrace . Propagate ( err , " " ) } defer tx . Rollback ( ) now := time . Now ( ) builder := sdb . Insert ( " " ) . Columns ( " " , " " , " " ) for _ , address := range addresses { builder = builder . Values ( address , amount , now ) } query , args , err := builder . Suffix ( `
		ON CONFLICT (rewards_address)
		DO UPDATE SET balance = reward_balance.balance + EXCLUDED.balance, updated_at = EXCLUDED.updated_at
		RETURNING rewards_address, balance, updated_at` ) . ToSql ( ) logger . Println ( query , args , err ) balances := [ ] * RewardBalance { } err = tx . Tx ( ) . Select ( & balances , query , args ... ) if err != nil { return nil , stacktrace . Propagate ( err , " " ) } return balances , stacktrace . Propagate ( tx . Commit ( ) , " " ) }
AdjustRewardBalanceOfAddresses adjusts the balance of the specified addresses by the specified amount
AdjustRewardBalanceOfAddresses adjusts the balance of the specified addresses by the specified amount