func adjustByOutputs(state types.AccountSetter, accounts map[string]*types.Account, outs []types.TxOutput, isCheckTx bool) { for _, out := range outs { acc := accounts[string(out.Address)] if acc == nil { PanicSanity("adjustByOutputs() expects account in accounts") } acc.Balance = acc.Balance.Plus(out.Coins) if !isCheckTx { state.SetAccount(out.Address, acc) } } }
func adjustByInputs(state types.AccountSetter, accounts map[string]*types.Account, ins []types.TxInput) { for _, in := range ins { acc := accounts[string(in.Address)] if acc == nil { PanicSanity("adjustByInputs() expects account in accounts") } if !acc.Balance.IsGTE(in.Coins) { PanicSanity("adjustByInputs() expects sufficient funds") } acc.Balance = acc.Balance.Minus(in.Coins) acc.Sequence += 1 state.SetAccount(in.Address, acc) } }