diff options
author | Sonic <sonic@cobinhood.com> | 2018-10-09 16:29:06 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:49 +0800 |
commit | e3ae45765337026fcb5dc484eca64951d833b34a (patch) | |
tree | 5ba5f49f17ffbfda495bb19a71bbe171e2adfe0c /dex | |
parent | 94ea114c5888736397c41730019798d78b58fd83 (diff) | |
download | dexon-e3ae45765337026fcb5dc484eca64951d833b34a.tar dexon-e3ae45765337026fcb5dc484eca64951d833b34a.tar.gz dexon-e3ae45765337026fcb5dc484eca64951d833b34a.tar.bz2 dexon-e3ae45765337026fcb5dc484eca64951d833b34a.tar.lz dexon-e3ae45765337026fcb5dc484eca64951d833b34a.tar.xz dexon-e3ae45765337026fcb5dc484eca64951d833b34a.tar.zst dexon-e3ae45765337026fcb5dc484eca64951d833b34a.zip |
dex: remove DAO related code
Diffstat (limited to 'dex')
-rw-r--r-- | dex/handler.go | 59 | ||||
-rw-r--r-- | dex/peer.go | 5 |
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 |