aboutsummaryrefslogtreecommitdiffstats
path: root/dex/peer.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-17 10:43:10 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:58 +0800
commit64f26af59d24881bcdd49bbdd291c1a21a12b82d (patch)
tree4968dc2006c6cabd118fc200b85bd05dc180efd0 /dex/peer.go
parent2818ad97f5b302f76e3296195bf8daae1868c435 (diff)
downloaddexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.tar
dexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.tar.gz
dexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.tar.bz2
dexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.tar.lz
dexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.tar.xz
dexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.tar.zst
dexon-64f26af59d24881bcdd49bbdd291c1a21a12b82d.zip
core: fill in genesis timstamp and remove dMoment from protocol handshake (#263)
Fill in dmoment as genesis block timestamp. This allow us to remove dMoment check from protocol handshake since genesis block hash itself will protect us against different dMoment.
Diffstat (limited to 'dex/peer.go')
-rw-r--r--dex/peer.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/dex/peer.go b/dex/peer.go
index 6a5786e1f..e015ed9e5 100644
--- a/dex/peer.go
+++ b/dex/peer.go
@@ -669,7 +669,7 @@ func (p *peer) RequestReceipts(hashes []common.Hash) error {
// Handshake executes the eth protocol handshake, negotiating version number,
// network IDs, difficulties, head and genesis blocks.
-func (p *peer) Handshake(network uint64, dMoment uint64, number uint64, head common.Hash, genesis common.Hash) error {
+func (p *peer) Handshake(network uint64, number uint64, head common.Hash, genesis common.Hash) error {
// Send out own handshake in a new thread
errc := make(chan error, 2)
var status statusData // safe to read after two values have been received from errc
@@ -678,14 +678,13 @@ func (p *peer) Handshake(network uint64, dMoment uint64, number uint64, head com
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
ProtocolVersion: uint32(p.version),
NetworkId: network,
- DMoment: dMoment,
Number: number,
CurrentBlock: head,
GenesisBlock: genesis,
})
}()
go func() {
- errc <- p.readStatus(network, dMoment, &status, genesis)
+ errc <- p.readStatus(network, &status, genesis)
}()
timeout := time.NewTimer(handshakeTimeout)
defer timeout.Stop()
@@ -703,7 +702,7 @@ func (p *peer) Handshake(network uint64, dMoment uint64, number uint64, head com
return nil
}
-func (p *peer) readStatus(network uint64, dMoment uint64, status *statusData, genesis common.Hash) (err error) {
+func (p *peer) readStatus(network uint64, status *statusData, genesis common.Hash) (err error) {
msg, err := p.rw.ReadMsg()
if err != nil {
return err
@@ -724,9 +723,6 @@ func (p *peer) readStatus(network uint64, dMoment uint64, status *statusData, ge
if status.NetworkId != network {
return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, network)
}
- if status.DMoment != dMoment {
- return errResp(ErrDMomentMismatch, "%d (!= %d)", status.DMoment, dMoment)
- }
if int(status.ProtocolVersion) != p.version {
return errResp(ErrProtocolVersionMismatch, "%d (!= %d)", status.ProtocolVersion, p.version)
}