Skip to content

Commit

Permalink
Coding style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillt authored and Kirill Taran committed Mar 19, 2021
1 parent c998989 commit 740e44a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 34 deletions.
45 changes: 21 additions & 24 deletions code/go/0chain.net/chaincore/chain/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,30 +409,27 @@ func (c *Chain) updateState(b *block.Block, txn *transaction.Transaction) (
)

switch txn.TransactionType {
case transaction.TxnTypeSmartContract:
var output string
if output, err = c.ExecuteSmartContract(txn, sctx); err != nil {
Logger.Error("Error executing the SC", zap.Any("txn", txn),
zap.Error(err))
return
}
txn.TransactionOutput = output
Logger.Info("SC executed with output",
zap.Any("txn_output", txn.TransactionOutput),
zap.Any("txn_hash", txn.Hash))

case transaction.TxnTypeData:

case transaction.TxnTypeSend:
err = sctx.AddTransfer(state.NewTransfer(txn.ClientID, txn.ToClientID,
state.Balance(txn.Value)))
if err != nil {
return
}

default:
Logger.Error("Invalid transaction type", zap.Int("txn type", txn.TransactionType))
return fmt.Errorf("invalid transaction type: %v", txn.TransactionType)
case transaction.TxnTypeSmartContract:
var output string
if output, err = c.ExecuteSmartContract(txn, sctx); err != nil {
Logger.Error("Error executing the SC", zap.Any("txn", txn),
zap.Error(err))
return
}
txn.TransactionOutput = output
Logger.Info("SC executed with output",
zap.Any("txn_output", txn.TransactionOutput),
zap.Any("txn_hash", txn.Hash))
case transaction.TxnTypeData:
case transaction.TxnTypeSend:
err = sctx.AddTransfer(state.NewTransfer(txn.ClientID, txn.ToClientID,
state.Balance(txn.Value)))
if err != nil {
return
}
default:
Logger.Error("Invalid transaction type", zap.Int("txn type", txn.TransactionType))
return fmt.Errorf("invalid transaction type: %v", txn.TransactionType)
}

if config.DevConfiguration.IsFeeEnabled {
Expand Down
21 changes: 11 additions & 10 deletions code/go/0chain.net/smartcontract/minersc/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ func (c *Client) callAddToDelegatePool(t *testing.T, msc *MinerSmartContract,

t.Helper()

var tx = newTransaction(c.id, ADDRESS, value, now)
balances.(*testBalances).txn = tx

var pool delegatePool
pool.ConsensusNodeID = nodeId

var (
input = mustEncode(t, &pool)
pool delegatePool
global *GlobalNode
tx = newTransaction(c.id, ADDRESS, value, now)
)
global, err = msc.getGlobalNode(balances)
require.NoError(t, err, "missing global node")

balances.(*testBalances).txn = tx

pool.ConsensusNodeID = nodeId
var input = mustEncode(t, &pool)
return msc.addToDelegatePool(tx, input, global, balances)
}

Expand All @@ -172,15 +172,16 @@ func (c *Client) callAddMinerOrSharder(isMiner bool, t *testing.T,
balances cstate.StateContextI) (
resp string, err error) {

var tx = newTransaction(c.id, ADDRESS, 0, now)
balances.(*testBalances).txn = tx
var (
input = c.addNodeRequest(t, delegateWallet)
global *GlobalNode
tx = newTransaction(c.id, ADDRESS, 0, now)
input = c.addNodeRequest(t, delegateWallet)
)
global, err = msc.getGlobalNode(balances)
require.NoError(t, err, "missing global node")

balances.(*testBalances).txn = tx

if isMiner {
return msc.AddMiner(tx, input, global, balances)
} else {
Expand Down

0 comments on commit 740e44a

Please sign in to comment.