mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
change type packet from ping(1) to ping tomo(5)
This commit is contained in:
parent
7c55084785
commit
bf5318c4c9
2 changed files with 9 additions and 8 deletions
|
|
@ -63,6 +63,7 @@ const (
|
|||
pongPacket
|
||||
findnodePacket
|
||||
neighborsPacket
|
||||
pingTomo
|
||||
)
|
||||
|
||||
// RPC request structures
|
||||
|
|
@ -279,7 +280,7 @@ func (t *udp) ping(toid NodeID, toaddr *net.UDPAddr) error {
|
|||
To: makeEndpoint(toaddr, 0), // TODO: maybe use known TCP port from DB
|
||||
Expiration: uint64(time.Now().Add(expiration).Unix()),
|
||||
}
|
||||
packet, hash, err := encodePacket(t.priv, pingPacket, req)
|
||||
packet, hash, err := encodePacket(t.priv, pingTomo, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -291,7 +292,7 @@ func (t *udp) ping(toid NodeID, toaddr *net.UDPAddr) error {
|
|||
}
|
||||
|
||||
func (t *udp) waitping(from NodeID) error {
|
||||
return <-t.pending(from, pingPacket, func(interface{}) bool { return true })
|
||||
return <-t.pending(from, pingTomo, func(interface{}) bool { return true })
|
||||
}
|
||||
|
||||
// findnode sends a findnode request to the given node and waits until
|
||||
|
|
@ -563,7 +564,7 @@ func decodePacket(buf []byte) (packet, NodeID, []byte, error) {
|
|||
}
|
||||
var req packet
|
||||
switch ptype := sigdata[0]; ptype {
|
||||
case pingPacket:
|
||||
case pingTomo:
|
||||
req = new(ping)
|
||||
case pongPacket:
|
||||
req = new(pong)
|
||||
|
|
@ -588,14 +589,14 @@ func (req *ping) handle(t *udp, from *net.UDPAddr, fromID NodeID, mac []byte) er
|
|||
ReplyTok: mac,
|
||||
Expiration: uint64(time.Now().Add(expiration).Unix()),
|
||||
})
|
||||
if !t.handleReply(fromID, pingPacket, req) {
|
||||
if !t.handleReply(fromID, pingTomo, req) {
|
||||
// Note: we're ignoring the provided IP address right now
|
||||
go t.bond(true, fromID, from, req.From.TCP)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (req *ping) name() string { return "PING/v4" }
|
||||
func (req *ping) name() string { return "PING TOMO/v4" }
|
||||
|
||||
func (req *pong) handle(t *udp, from *net.UDPAddr, fromID NodeID, mac []byte) error {
|
||||
if expired(req.Expiration) {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func TestUDP_packetErrors(t *testing.T) {
|
|||
test := newUDPTest(t)
|
||||
defer test.table.Close()
|
||||
|
||||
test.packetIn(errExpired, pingPacket, &ping{From: testRemote, To: testLocalAnnounced, Version: Version})
|
||||
test.packetIn(errExpired, pingTomo, &ping{From: testRemote, To: testLocalAnnounced, Version: Version})
|
||||
test.packetIn(errUnsolicitedReply, pongPacket, &pong{ReplyTok: []byte{}, Expiration: futureExp})
|
||||
test.packetIn(errUnknownNode, findnodePacket, &findnode{Expiration: futureExp})
|
||||
test.packetIn(errUnsolicitedReply, neighborsPacket, &neighbors{Expiration: futureExp})
|
||||
|
|
@ -328,7 +328,7 @@ func TestUDP_successfulPing(t *testing.T) {
|
|||
defer test.table.Close()
|
||||
|
||||
// The remote side sends a ping packet to initiate the exchange.
|
||||
go test.packetIn(nil, pingPacket, &ping{From: testRemote, To: testLocalAnnounced, Version: Version, Expiration: futureExp})
|
||||
go test.packetIn(nil, pingTomo, &ping{From: testRemote, To: testLocalAnnounced, Version: Version, Expiration: futureExp})
|
||||
|
||||
// the ping is replied to.
|
||||
test.waitPacketOut(func(p *pong) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue