Skip to content

Commit

Permalink
pr nit
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Oct 31, 2024
1 parent 9ca4ae7 commit 3d26583
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion p2p/transport/tcpreuse/demultiplex.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
manet "github.com/multiformats/go-multiaddr/net"
)

// This is readiung the first 3 bytes of the packet. It should be instant.
const identifyConnTimeout = 1 * time.Second

type DemultiplexedConnType int

const (
Expand Down Expand Up @@ -40,7 +43,7 @@ func (t DemultiplexedConnType) IsKnown() bool {
// It Callers must not use the passed in Conn after this
// function returns. if an error is returned, the connection will be closed.
func identifyConnType(c manet.Conn) (DemultiplexedConnType, manet.Conn, error) {
if err := c.SetReadDeadline(time.Now().Add(1 * time.Second)); err != nil {
if err := c.SetReadDeadline(time.Now().Add(identifyConnTimeout)); err != nil {
closeErr := c.Close()
return 0, nil, errors.Join(err, closeErr)
}
Expand Down

0 comments on commit 3d26583

Please sign in to comment.