diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-01-14 19:59:57 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:56 +0800 |
commit | 3fcb8b6825b3c62c9890a5ca59594f1503e66893 (patch) | |
tree | abdf747d608dfd9079290db404148bd1944c969a /dex/peer.go | |
parent | 723d86122198314589d98f59b0176d60d2d5c878 (diff) | |
download | go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.tar go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.tar.gz go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.tar.bz2 go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.tar.lz go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.tar.xz go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.tar.zst go-tangerine-3fcb8b6825b3c62c9890a5ca59594f1503e66893.zip |
params: write dMoment into ChainConfig (#150)
Diffstat (limited to 'dex/peer.go')
-rw-r--r-- | dex/peer.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/dex/peer.go b/dex/peer.go index 295c5c400..0a67db688 100644 --- a/dex/peer.go +++ b/dex/peer.go @@ -631,7 +631,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, number uint64, head common.Hash, genesis common.Hash) error { +func (p *peer) Handshake(network uint64, dMoment 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 @@ -640,13 +640,14 @@ func (p *peer) Handshake(network uint64, number uint64, head common.Hash, genesi 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, &status, genesis) + errc <- p.readStatus(network, dMoment, &status, genesis) }() timeout := time.NewTimer(handshakeTimeout) defer timeout.Stop() @@ -664,7 +665,7 @@ func (p *peer) Handshake(network uint64, number uint64, head common.Hash, genesi return nil } -func (p *peer) readStatus(network uint64, status *statusData, genesis common.Hash) (err error) { +func (p *peer) readStatus(network uint64, dMoment uint64, status *statusData, genesis common.Hash) (err error) { msg, err := p.rw.ReadMsg() if err != nil { return err @@ -685,6 +686,9 @@ func (p *peer) readStatus(network uint64, status *statusData, genesis common.Has 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) } |