aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-09 16:29:06 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 20:54:27 +0800
commit0169f4f82de60feabb16b6b6eb0f93b304b9755f (patch)
treebb1d0342ad8c0d2ed9b4d83cfb6b82776b9f35f6
parentf54b89781ed7337653e4cc0ab5c591aea91390de (diff)
downloaddexon-0169f4f82de60feabb16b6b6eb0f93b304b9755f.tar.gz
dexon-0169f4f82de60feabb16b6b6eb0f93b304b9755f.tar.zst
dexon-0169f4f82de60feabb16b6b6eb0f93b304b9755f.zip
dex: remove DAO related code
-rw-r--r--dex/handler.go59
-rw-r--r--dex/peer.go5
2 files changed, 2 insertions, 62 deletions
diff --git a/dex/handler.go b/dex/handler.go
index 5348b06f2..67cbe8a63 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -28,7 +28,6 @@ import (
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/consensus"
- "github.com/dexon-foundation/dexon/consensus/misc"
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/core/types"
"github.com/dexon-foundation/dexon/eth/downloader"
@@ -53,10 +52,6 @@ const (
metaChanSize = 10240
)
-var (
- daoChallengeTimeout = 15 * time.Second // Time allowance for a node to reply to the DAO handshake challenge
-)
-
// errIncompatibleConfig is returned if the requested protocols and configs are
// not compatible (low protocol version restrictions and high requirements).
var errIncompatibleConfig = errors.New("incompatible configuration")
@@ -316,25 +311,6 @@ func (pm *ProtocolManager) handle(p *peer) error {
pm.syncTransactions(p)
pm.syncNodeMetas(p)
- // If we're DAO hard-fork aware, validate any remote peer with regard to the hard-fork
- if daoBlock := pm.chainconfig.DAOForkBlock; daoBlock != nil {
- // Request the peer's DAO fork header for extra-data validation
- if err := p.RequestHeadersByNumber(daoBlock.Uint64(), 1, 0, false); err != nil {
- return err
- }
- // Start a timer to disconnect if the peer doesn't reply in time
- p.forkDrop = time.AfterFunc(daoChallengeTimeout, func() {
- p.Log().Debug("Timed out DAO fork-check, dropping")
- pm.removePeer(p.id)
- })
- // Make sure it's cleaned up if the peer dies off
- defer func() {
- if p.forkDrop != nil {
- p.forkDrop.Stop()
- p.forkDrop = nil
- }
- }()
- }
// main loop. handle incoming messages.
for {
if err := pm.handleMsg(p); err != nil {
@@ -457,44 +433,9 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
if err := msg.Decode(&headers); err != nil {
return errResp(ErrDecode, "msg %v: %v", msg, err)
}
- // If no headers were received, but we're expending a DAO fork check, maybe it's that
- if len(headers) == 0 && p.forkDrop != nil {
- // Possibly an empty reply to the fork header checks, sanity check TDs
- verifyDAO := true
-
- // If we already have a DAO header, we can check the peer's TD against it. If
- // the peer's ahead of this, it too must have a reply to the DAO check
- if daoHeader := pm.blockchain.GetHeaderByNumber(pm.chainconfig.DAOForkBlock.Uint64()); daoHeader != nil {
- if _, td := p.Head(); td.Cmp(pm.blockchain.GetTd(daoHeader.Hash(), daoHeader.Number.Uint64())) >= 0 {
- verifyDAO = false
- }
- }
- // If we're seemingly on the same chain, disable the drop timer
- if verifyDAO {
- p.Log().Debug("Seems to be on the same side of the DAO fork")
- p.forkDrop.Stop()
- p.forkDrop = nil
- return nil
- }
- }
// Filter out any explicitly requested headers, deliver the rest to the downloader
filter := len(headers) == 1
if filter {
- // If it's a potential DAO fork check, validate against the rules
- if p.forkDrop != nil && pm.chainconfig.DAOForkBlock.Cmp(headers[0].Number) == 0 {
- // Disable the fork drop timer
- p.forkDrop.Stop()
- p.forkDrop = nil
-
- // Validate the header and either drop the peer or continue
- if err := misc.VerifyDAOHeaderExtraData(pm.chainconfig, headers[0]); err != nil {
- p.Log().Debug("Verified to be on the other side of the DAO fork, dropping")
- return err
- }
- p.Log().Debug("Verified to be on the same side of the DAO fork")
- return nil
- }
- // Irrelevant of the fork checks, send the header to the fetcher just in case
headers = pm.fetcher.FilterHeaders(p.id, headers, time.Now())
}
if len(headers) > 0 || !filter {
diff --git a/dex/peer.go b/dex/peer.go
index 8c218f1d9..05947b456 100644
--- a/dex/peer.go
+++ b/dex/peer.go
@@ -97,9 +97,8 @@ type peer struct {
*p2p.Peer
rw p2p.MsgReadWriter
- version int // Protocol version negotiated
- labels mapset.Set
- forkDrop *time.Timer // Timed connection dropper if forks aren't validated in time
+ version int // Protocol version negotiated
+ labels mapset.Set
head common.Hash
td *big.Int