From 8b0b015937c02207df440eee6e4c96eec846fae6 Mon Sep 17 00:00:00 2001 From: bojie Date: Mon, 26 Nov 2018 09:16:12 +0800 Subject: app: skip tx which has been confirmed (#45) * app: skip tx which has been confirmed * fixup! app: skip tx which has been confirmed --- dex/app.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'dex/app.go') diff --git a/dex/app.go b/dex/app.go index df76b2b7d..623bb8dff 100644 --- a/dex/app.go +++ b/dex/app.go @@ -200,16 +200,15 @@ addressMap: expectNonce = lastConfirmedNonce + 1 } - for _, tx := range txs { - if expectNonce == tx.Nonce() { - expectNonce++ - } else if expectNonce < tx.Nonce() { - break - } else if expectNonce > tx.Nonce() { - log.Debug("Skipping tx with smaller nonce then expected", "expected", expectNonce, "nonce", tx.Nonce()) - continue - } + if len(txs) == 0 { + continue + } + + firstNonce := txs[0].Nonce() + startIndex := int(expectNonce - firstNonce) + for i := startIndex; i < len(txs); i++ { + tx := txs[i] intrGas, err := core.IntrinsicGas(tx.Data(), tx.To() == nil, true) if err != nil { log.Error("Failed to calculate intrinsic gas", "error", err) -- cgit v1.2.3