From 3478de50a166e1411f0576e0ac0f4e2f4233632c Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 10 Apr 2017 22:41:07 +0400 Subject: [PATCH] no need for map - tx responses should arrive in order (Refs #237) ``` me: so we are executing them in order and receiving them in order and there is no way we could receive them out of order (due to network or something else), correct? ebuchman: if we receive them out of order, ABCI is broken ebuchman: so it is possible, if the ABCI server we're talking to is not implementing the spec ebuchman: but that shouldn't justify us building a map ``` --- state/execution.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/state/execution.go b/state/execution.go index bc125d4e3..5f0df6133 100644 --- a/state/execution.go +++ b/state/execution.go @@ -65,11 +65,7 @@ func execBlockOnProxyApp(eventCache types.Fireable, proxyAppConn proxy.AppConnCo var validTxs, invalidTxs = 0, 0 txResults := make([]*types.TxResult, len(block.Txs)) - - txHashToIndexMap := make(map[string]int) - for index, tx := range block.Txs { - txHashToIndexMap[string(tx.Hash())] = index - } + txIndex := 0 // Execute transactions and get hash proxyCb := func(req *abci.Request, res *abci.Response) { @@ -89,16 +85,13 @@ func execBlockOnProxyApp(eventCache types.Fireable, proxyAppConn proxy.AppConnCo txError = txResult.Code.String() } - tx := types.Tx(req.GetDeliverTx().Tx) - index, ok := txHashToIndexMap[string(tx.Hash())] - if ok { - txResults[index] = &types.TxResult{uint64(block.Height), uint32(index), *txResult} - } + txResults[txIndex] = &types.TxResult{uint64(block.Height), uint32(txIndex), *txResult} + txIndex++ // NOTE: if we count we can access the tx from the block instead of // pulling it from the req event := types.EventDataTx{ - Tx: tx, + Tx: types.Tx(req.GetDeliverTx().Tx), Data: txResult.Data, Code: txResult.Code, Log: txResult.Log,