aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-03-27 14:23:19 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:50:05 +0800
commitf8965e35ce4ee76187cb8c479bec99638f93efc2 (patch)
treefe9106efb9f7e95200f1a4172670e6bff00219d7
parentf500ef0a50518133ef679f7d3f9c41d8d11bcbf5 (diff)
downloaddexon-f8965e35ce4ee76187cb8c479bec99638f93efc2.tar.gz
dexon-f8965e35ce4ee76187cb8c479bec99638f93efc2.tar.zst
dexon-f8965e35ce4ee76187cb8c479bec99638f93efc2.zip
dex: fix missing trie node when fast syncing (#301)
* dex: don't panic when we don't have gov state peer requested * dex: use correct head block Since we are fast syncing, we probably don't have body, receipt, state
-rw-r--r--dex/handler.go5
-rw-r--r--dex/protocol.go1
2 files changed, 4 insertions, 2 deletions
diff --git a/dex/handler.go b/dex/handler.go
index 84170e54b..ec5704103 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -361,7 +361,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
// Execute the Ethereum handshake
var (
genesis = pm.blockchain.Genesis()
- head = pm.blockchain.CurrentHeader()
+ head = pm.blockchain.CurrentBlock().Header()
hash = head.Hash()
number = head.Number.Uint64()
)
@@ -953,7 +953,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
govState, err := pm.blockchain.GetGovStateByHash(hash)
if err != nil {
- panic(err)
+ p.Log().Debug("Invalid gov state msg", "hash", hash.String(), "err", err)
+ return errResp(ErrInvalidGovStateMsg, "hash=%v", hash.String())
}
return p.SendGovState(govState)
case msg.Code == GovStateMsg:
diff --git a/dex/protocol.go b/dex/protocol.go
index e09829cc8..639925265 100644
--- a/dex/protocol.go
+++ b/dex/protocol.go
@@ -110,6 +110,7 @@ const (
ErrNoStatusMsg
ErrExtraStatusMsg
ErrSuspendedPeer
+ ErrInvalidGovStateMsg
)
const (