add xdpos2 protocol condition

This commit is contained in:
wanwiset25 2024-05-27 14:54:11 +04:00
parent 1b781530c6
commit 9e04fd82cf
2 changed files with 20 additions and 0 deletions

View file

@ -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),

View file

@ -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: