ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.47k stars 20.1k forks source link

p2p, why return known state? #17600

Closed shanhuhai5739 closed 6 years ago

shanhuhai5739 commented 6 years ago

Hi there, p2p, why return known state? https://github.com/ethereum/go-ethereum/blob/master/p2p/discv5/net.go#L952

    remoteverifywait = &nodeState{
        name: "remoteverifywait",
        enter: func(net *Network, n *Node) {
            net.timedEvent(respTimeout, n, pingTimeout)
        },
        handle: func(net *Network, n *Node, ev nodeEvent, pkt *ingressPacket) (*nodeState, error) {
            switch ev {
            case pingPacket:
                net.handlePing(n, pkt)
                return remoteverifywait, nil
            case pingTimeout:
                return known, nil
            default:
                return remoteverifywait, errInvalidEvent
            }
        },
    }
shanhuhai5739 commented 6 years ago

I think, it should be unknown state if handle pingTimeout

shanhuhai5739 commented 6 years ago

hello anybody here?

fjl commented 6 years ago

It returns to known state because the other side had a chance to ping, but didn't use it. We will remove p2p/discv5 code soon, no need to worry about this code :)

0xmountaintop commented 6 years ago

It returns to known state because the other side had a chance to ping, but didn't use it. We will remove p2p/discv5 code soon, no need to worry about this code :)

what does "it" refer to in "but didn't use it"? am i correct that a normal peer will not ping, even if it has a chance, so we won't run into the consequent known state?