aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorBJ4 <bojie@dexon.org>2018-11-15 16:23:21 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:18 +0800
commit7309a991020a78dd389dd851b9b496d6bdf928bb (patch)
tree7c9773c381a2885187f622401f6567dc12bfe309 /dex
parentd945ea451bece3c8e230ae017dd443266633d634 (diff)
downloadgo-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.tar
go-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.tar.gz
go-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.tar.bz2
go-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.tar.lz
go-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.tar.xz
go-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.tar.zst
go-tangerine-7309a991020a78dd389dd851b9b496d6bdf928bb.zip
app: remove notify to prevent dead lock with consensus core
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go42
1 files changed, 3 insertions, 39 deletions
diff --git a/dex/app.go b/dex/app.go
index 38ca382e3..e0280dc2c 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -79,40 +79,6 @@ func NewDexconApp(txPool *core.TxPool, blockchain *core.BlockChain, gov *DexconG
}
}
-func (d *DexconApp) addNotify(height uint64) <-chan uint64 {
- d.notifyMu.Lock()
- defer d.notifyMu.Unlock()
-
- result := make(chan uint64)
- v, ok := d.notifyChan.Load(height)
- if ok {
- n := v.(*notify)
- n.results = append(n.results, result)
- } else {
- n := &notify{results: []chan uint64{result}}
- d.notifyChan.Store(height, n)
- }
- return result
-}
-
-func (d *DexconApp) notify(height uint64) {
- d.notifyMu.Lock()
- defer d.notifyMu.Unlock()
-
- d.notifyChan.Range(func(key, value interface{}) bool {
- h := key.(uint64)
- n := value.(*notify)
-
- if height >= h {
- for _, ch := range n.results {
- ch <- height
- }
- d.notifyChan.Delete(key)
- }
- return true
- })
-}
-
func (d *DexconApp) addrBelongsToChain(address common.Address, chainSize, chainID *big.Int) bool {
return new(big.Int).Mod(address.Big(), chainSize).Cmp(chainID) == 0
}
@@ -280,11 +246,10 @@ func (d *DexconApp) PrepareWitness(consensusHeight uint64) (witness coreTypes.Wi
witnessBlock = d.blockchain.CurrentBlock()
} else if lastPendingHeight >= consensusHeight {
witnessBlock = d.blockchain.GetPendingBlock()
- } else if h := <-d.addNotify(consensusHeight); h >= consensusHeight {
- witnessBlock = d.blockchain.GetPendingBlock()
} else {
- log.Error("need pending block")
- return witness, fmt.Errorf("need pending block")
+ log.Error("last pending height too low", "lastPendingHeight", lastPendingHeight,
+ "consensusHeight", consensusHeight)
+ return witness, fmt.Errorf("last pending height < consensus height")
}
witnessData, err := rlp.EncodeToBytes(&witnessData{
@@ -489,7 +454,6 @@ func (d *DexconApp) BlockDelivered(
log.Info("Insert pending block success", "height", result.Height)
d.blockchain.RemoveConfirmedBlock(chainID, blockHash)
- d.notify(result.Height)
}
// BlockConfirmed is called when a block is confirmed and added to lattice.