Skip to content

Commit

Permalink
Merge pull request #65 from bluele/fix/increment-txidx
Browse files Browse the repository at this point in the history
Increment tx counter correctly
  • Loading branch information
bluele authored Oct 11, 2019
2 parents 6a08865 + a58a1ee commit 69729e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/contract/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (env *Env) Exec(ctx sdk.Context, entry string) (*Result, error) {
res := env.GetReponse()
if code < 0 {
// TODO add error msg from call stacks
return &Result{Code: code, Response: res}, fmt.Errorf("execute contract error exitcode=%v description=%v", code, string(res))
return &Result{Code: code, Response: res}, fmt.Errorf("failed to execute contract exitcode=%v description=%v", code, string(res))
}

// Update state
Expand Down
6 changes: 2 additions & 4 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ func NewHandler(txm transaction.TxIndexMapper, am account.AccountMapper, cm *con
return func(ctx types.Context, tx types.Tx) (res types.Result) {
ctx = ctx.WithTxIndex(txm.Get(ctx))
defer func() {
if res.IsOK() {
txm.Incr(ctx)
}
txm.Incr(ctx)
}()
switch tx := tx.(type) {
case *transaction.TransferTx:
Expand Down Expand Up @@ -69,7 +67,7 @@ func handleContractCallTx(ctx types.Context, cm *contract.ContractManager, envm
return transaction.ErrInvalidCall(transaction.DefaultCodespace, err.Error()).Result()
}
if len(tx.RWSetsHash) != 0 && !bytes.Equal(tx.RWSetsHash, res.State.RWSets().Hash()) {
return transaction.ErrInvalidCall(transaction.DefaultCodespace, fmt.Sprintf("RWSetsHash mismatch %v %v", tx.RWSetsHash, res.State.RWSets().Hash())).Result()
return transaction.ErrInvalidCall(transaction.DefaultCodespace, fmt.Sprintf("unexpected RWSetsHash %X != %X", tx.RWSetsHash, res.State.RWSets().Hash())).Result()
}
b, err := res.State.RWSets().Bytes()
if err != nil {
Expand Down

0 comments on commit 69729e7

Please sign in to comment.