From 9e04fd82cf2bd2797c45de543e5d49e5a08052fe Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Mon, 27 May 2024 14:54:11 +0400 Subject: [PATCH] add xdpos2 protocol condition --- eth/helper_test.go | 8 ++++++++ eth/peer.go | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/eth/helper_test.go b/eth/helper_test.go index 3f25658586..fc7775794d 100644 --- a/eth/helper_test.go +++ b/eth/helper_test.go @@ -207,6 +207,14 @@ func newTestPeer(name string, version int, pm *ProtocolManager, shake bool) (*te func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesis common.Hash, forkID forkid.ID, forkFilter forkid.Filter) { var msg interface{} switch { + case p.version == xdpos2: + msg = &statusData63{ + ProtocolVersion: uint32(p.version), + NetworkId: DefaultConfig.NetworkId, + TD: td, + CurrentBlock: head, + GenesisBlock: genesis, + } case p.version == eth63: msg = &statusData63{ ProtocolVersion: uint32(p.version), diff --git a/eth/peer.go b/eth/peer.go index 5e1a7a29ec..c468f89830 100644 --- a/eth/peer.go +++ b/eth/peer.go @@ -783,6 +783,14 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis ) go func() { switch { + case p.version == xdpos2: + errc <- p2p.Send(p.rw, StatusMsg, &statusData63{ + ProtocolVersion: uint32(p.version), + NetworkId: network, + TD: td, + CurrentBlock: head, + GenesisBlock: genesis, + }) case p.version == eth63: errc <- p2p.Send(p.rw, StatusMsg, &statusData63{ ProtocolVersion: uint32(p.version), @@ -806,6 +814,8 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis }() go func() { switch { + case p.version == xdpos2: + errc <- p.readStatusLegacy(network, &status63, genesis) case p.version == eth63: errc <- p.readStatusLegacy(network, &status63, genesis) case p.version >= eth64: @@ -827,6 +837,8 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis } } switch { + case p.version == xdpos2: + p.td, p.head = status63.TD, status63.CurrentBlock case p.version == eth63: p.td, p.head = status63.TD, status63.CurrentBlock case p.version >= eth64: