aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorBojie Wu <bojie@dexon.org>2018-10-09 13:28:45 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:49:55 +0800
commit54475de2eab21d798d39b372efb8e9381f32fbc2 (patch)
tree7d2e1e4a83fb9dadce586e7d450f31f5a3557026 /dex
parentf49211457b3763979ccbaea12b9dce6e8625e768 (diff)
downloaddexon-54475de2eab21d798d39b372efb8e9381f32fbc2.tar
dexon-54475de2eab21d798d39b372efb8e9381f32fbc2.tar.gz
dexon-54475de2eab21d798d39b372efb8e9381f32fbc2.tar.bz2
dexon-54475de2eab21d798d39b372efb8e9381f32fbc2.tar.lz
dexon-54475de2eab21d798d39b372efb8e9381f32fbc2.tar.xz
dexon-54475de2eab21d798d39b372efb8e9381f32fbc2.tar.zst
dexon-54475de2eab21d798d39b372efb8e9381f32fbc2.zip
app: fix bug when prepare transaction
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/dex/app.go b/dex/app.go
index 577135dc0..d5b7d3556 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -160,6 +160,8 @@ func (d *DexconApp) PreparePayload(position coreTypes.Position) (payload []byte,
blockGasLimit := new(big.Int).SetUint64(core.CalcGasLimit(d.blockchain.CurrentBlock(), d.config.GasFloor, d.config.GasCeil))
blockGasUsed := new(big.Int)
var allTxs types.Transactions
+
+addressMap:
for address, txs := range txsMap {
// every address's transactions will appear in fixed chain
if !d.checkChain(address, chainNums, chainID) {
@@ -217,8 +219,7 @@ func (d *DexconApp) PreparePayload(position coreTypes.Position) (payload []byte,
blockGasUsed = new(big.Int).Add(blockGasUsed, new(big.Int).SetUint64(tx.Gas()))
if blockGasLimit.Cmp(blockGasUsed) < 0 {
- log.Error("Reach block gas limit", "limit", blockGasLimit, "gasUsed", blockGasUsed)
- return nil, fmt.Errorf("reach block gas limit %v", blockGasLimit)
+ break addressMap
}
allTxs = append(allTxs, tx)
@@ -238,9 +239,13 @@ func (d *DexconApp) PrepareWitness(consensusHeight uint64) (witness coreTypes.Wi
if d.lastPendingHeight == 0 && consensusHeight == 0 {
witnessBlock = d.blockchain.CurrentBlock()
} else if d.lastPendingHeight >= consensusHeight {
+ d.insertMu.Lock()
witnessBlock = d.blockchain.GetPendingBlockByHeight(d.lastPendingHeight)
+ d.insertMu.Unlock()
} else if h := <-d.addNotify(consensusHeight); h >= consensusHeight {
+ d.insertMu.Lock()
witnessBlock = d.blockchain.GetPendingBlockByHeight(h)
+ d.insertMu.Unlock()
} else {
log.Error("need pending block")
return witness, fmt.Errorf("need pending block")