Browse Source

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
```
pull/412/head
Anton Kaliaev 7 years ago
parent
commit
3478de50a1
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 4 additions and 11 deletions
  1. +4
    -11
      state/execution.go

+ 4
- 11
state/execution.go View File

@ -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,


Loading…
Cancel
Save