diff options
author | Sonic <sonic@dexon.org> | 2018-11-22 15:09:49 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | b45aaef1780d9ad225792497752ba4b74cb4f7e9 (patch) | |
tree | 7cc52a2aa3cd6ac867e4caf65c20f5104e5cff96 /dex/handler.go | |
parent | e002e5cf9cdabb3657c7dc07d3b69d9ffd390265 (diff) | |
download | dexon-b45aaef1780d9ad225792497752ba4b74cb4f7e9.tar.gz dexon-b45aaef1780d9ad225792497752ba4b74cb4f7e9.tar.zst dexon-b45aaef1780d9ad225792497752ba4b74cb4f7e9.zip |
core, dex, downloader: refactor governance
Diffstat (limited to 'dex/handler.go')
-rw-r--r-- | dex/handler.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/dex/handler.go b/dex/handler.go index a86a68329..b4499ae5a 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -34,7 +34,6 @@ package dex import ( - "context" "encoding/json" "errors" "fmt" @@ -495,7 +494,6 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { } } - ctx := context.Background() if query.WithGov && len(headers) > 0 { last := headers[len(headers)-1] currentBlock := pm.blockchain.CurrentBlock() @@ -513,11 +511,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { if r == 0 { continue } - h, err := pm.gov.GetRoundHeight(ctx, r) - if err != nil { - log.Warn("Get round height fail", "err", err) - return p.SendBlockHeaders([]*types.HeaderWithGovState{}) - } + h := pm.gov.GetRoundHeight(r) log.Trace("#Snapshot height", "height", h) if h == 0 { h = height @@ -1181,7 +1175,9 @@ func (pm *ProtocolManager) peerSetLoop() { } if newRound == round+1 { pm.peers.BuildConnection(newRound) - pm.peers.ForgetConnection(round - 1) + if round >= 1 { + pm.peers.ForgetConnection(round - 1) + } } else { // just forget all network connection and rebuild. pm.peers.ForgetConnection(round) |