forked from cerc-io/plugeth
p2p/discover: fix typos in comments (#25272)
This commit is contained in:
parent
d839515434
commit
b3fc9574ec
@ -108,7 +108,7 @@ func sntpDrift(measurements int) (time.Duration, error) {
|
|||||||
// Calculate the drift based on an assumed answer time of RRT/2
|
// Calculate the drift based on an assumed answer time of RRT/2
|
||||||
drifts = append(drifts, sent.Sub(t)+elapsed/2)
|
drifts = append(drifts, sent.Sub(t)+elapsed/2)
|
||||||
}
|
}
|
||||||
// Calculate average drif (drop two extremities to avoid outliers)
|
// Calculate average drift (drop two extremities to avoid outliers)
|
||||||
sort.Sort(durationSlice(drifts))
|
sort.Sort(durationSlice(drifts))
|
||||||
|
|
||||||
drift := time.Duration(0)
|
drift := time.Duration(0)
|
||||||
|
@ -134,8 +134,8 @@ func newPingRecorder() *pingRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setRecord updates a node record. Future calls to ping and
|
// updateRecord updates a node record. Future calls to ping and
|
||||||
// requestENR will return this record.
|
// RequestENR will return this record.
|
||||||
func (t *pingRecorder) updateRecord(n *enode.Node) {
|
func (t *pingRecorder) updateRecord(n *enode.Node) {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
defer t.mu.Unlock()
|
defer t.mu.Unlock()
|
||||||
@ -162,7 +162,7 @@ func (t *pingRecorder) ping(n *enode.Node) (seq uint64, err error) {
|
|||||||
return seq, nil
|
return seq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// requestENR simulates an ENR request.
|
// RequestENR simulates an ENR request.
|
||||||
func (t *pingRecorder) RequestENR(n *enode.Node) (*enode.Node, error) {
|
func (t *pingRecorder) RequestENR(n *enode.Node) (*enode.Node, error) {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
defer t.mu.Unlock()
|
defer t.mu.Unlock()
|
||||||
|
@ -334,7 +334,7 @@ func (t *UDPv4) findnode(toid enode.ID, toaddr *net.UDPAddr, target v4wire.Pubke
|
|||||||
return nodes, err
|
return nodes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequestENR sends enrRequest to the given node and waits for a response.
|
// RequestENR sends ENRRequest to the given node and waits for a response.
|
||||||
func (t *UDPv4) RequestENR(n *enode.Node) (*enode.Node, error) {
|
func (t *UDPv4) RequestENR(n *enode.Node) (*enode.Node, error) {
|
||||||
addr := &net.UDPAddr{IP: n.IP(), Port: n.UDP()}
|
addr := &net.UDPAddr{IP: n.IP(), Port: n.UDP()}
|
||||||
t.ensureBond(n.ID(), addr)
|
t.ensureBond(n.ID(), addr)
|
||||||
|
@ -490,7 +490,7 @@ func TestUDPv4_EIP868(t *testing.T) {
|
|||||||
t.Fatalf("invalid record: %v", err)
|
t.Fatalf("invalid record: %v", err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(n, wantNode) {
|
if !reflect.DeepEqual(n, wantNode) {
|
||||||
t.Fatalf("wrong node in enrResponse: %v", n)
|
t.Fatalf("wrong node in ENRResponse: %v", n)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -86,16 +86,16 @@ type (
|
|||||||
Rest []rlp.RawValue `rlp:"tail"`
|
Rest []rlp.RawValue `rlp:"tail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// enrRequest queries for the remote node's record.
|
// ENRRequest queries for the remote node's record.
|
||||||
ENRRequest struct {
|
ENRRequest struct {
|
||||||
Expiration uint64
|
Expiration uint64
|
||||||
// Ignore additional fields (for forward compatibility).
|
// Ignore additional fields (for forward compatibility).
|
||||||
Rest []rlp.RawValue `rlp:"tail"`
|
Rest []rlp.RawValue `rlp:"tail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// enrResponse is the reply to enrRequest.
|
// ENRResponse is the reply to ENRRequest.
|
||||||
ENRResponse struct {
|
ENRResponse struct {
|
||||||
ReplyTok []byte // Hash of the enrRequest packet.
|
ReplyTok []byte // Hash of the ENRRequest packet.
|
||||||
Record enr.Record
|
Record enr.Record
|
||||||
// Ignore additional fields (for forward compatibility).
|
// Ignore additional fields (for forward compatibility).
|
||||||
Rest []rlp.RawValue `rlp:"tail"`
|
Rest []rlp.RawValue `rlp:"tail"`
|
||||||
|
@ -347,7 +347,7 @@ func (t *UDPv5) ping(n *enode.Node) (uint64, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// requestENR requests n's record.
|
// RequestENR requests n's record.
|
||||||
func (t *UDPv5) RequestENR(n *enode.Node) (*enode.Node, error) {
|
func (t *UDPv5) RequestENR(n *enode.Node) (*enode.Node, error) {
|
||||||
nodes, err := t.findnode(n, []uint{0})
|
nodes, err := t.findnode(n, []uint{0})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -300,7 +300,7 @@ func (c *Codec) encodeWhoareyou(toID enode.ID, packet *Whoareyou) (Header, error
|
|||||||
return head, nil
|
return head, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeHandshakeMessage encodes the handshake message packet header.
|
// encodeHandshakeHeader encodes the handshake message packet header.
|
||||||
func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Whoareyou) (Header, *session, error) {
|
func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Whoareyou) (Header, *session, error) {
|
||||||
// Ensure calling code sets challenge.node.
|
// Ensure calling code sets challenge.node.
|
||||||
if challenge.Node == nil {
|
if challenge.Node == nil {
|
||||||
@ -337,7 +337,7 @@ func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Who
|
|||||||
return head, session, err
|
return head, session, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeAuthHeader creates the auth header on a request packet following WHOAREYOU.
|
// makeHandshakeAuth creates the auth header on a request packet following WHOAREYOU.
|
||||||
func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoareyou) (*handshakeAuthData, *session, error) {
|
func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoareyou) (*handshakeAuthData, *session, error) {
|
||||||
auth := new(handshakeAuthData)
|
auth := new(handshakeAuthData)
|
||||||
auth.h.SrcID = c.localnode.ID()
|
auth.h.SrcID = c.localnode.ID()
|
||||||
@ -379,7 +379,7 @@ func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoarey
|
|||||||
return auth, sec, err
|
return auth, sec, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeMessage encodes an encrypted message packet.
|
// encodeMessageHeader encodes an encrypted message packet.
|
||||||
func (c *Codec) encodeMessageHeader(toID enode.ID, s *session) (Header, error) {
|
func (c *Codec) encodeMessageHeader(toID enode.ID, s *session) (Header, error) {
|
||||||
head := c.makeHeader(toID, flagMessage, 0)
|
head := c.makeHeader(toID, flagMessage, 0)
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ func (h *StaticHeader) checkValid(packetLen int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// headerMask returns a cipher for 'masking' / 'unmasking' packet headers.
|
// mask returns a cipher for 'masking' / 'unmasking' packet headers.
|
||||||
func (h *Header) mask(destID enode.ID) cipher.Stream {
|
func (h *Header) mask(destID enode.ID) cipher.Stream {
|
||||||
block, err := aes.NewCipher(destID[:16])
|
block, err := aes.NewCipher(destID[:16])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user