github.com/pure-x-eth/consensus_tm@v0.0.0-20230502163723-e3c2ff987250/p2p/conn/conn_notgo110.go (about) 1 //go:build !go1.10 2 // +build !go1.10 3 4 package conn 5 6 import ( 7 "net" 8 "time" 9 ) 10 11 // Only Go1.10 has a proper net.Conn implementation that 12 // has the SetDeadline method implemented as per 13 // 14 // https://github.com/golang/go/commit/e2dd8ca946be884bb877e074a21727f1a685a706 15 // 16 // lest we run into problems like 17 // 18 // https://github.com/pure-x-eth/consensus_tm/issues/851 19 // 20 // so for go versions < Go1.10 use our custom net.Conn creator 21 // that doesn't return an `Unimplemented error` for net.Conn. 22 // Before https://github.com/pure-x-eth/consensus_tm/commit/49faa79bdce5663894b3febbf4955fb1d172df04 23 // we hadn't cared about errors from SetDeadline so swallow them up anyways. 24 type pipe struct { 25 net.Conn 26 } 27 28 func (p *pipe) SetDeadline(t time.Time) error { 29 return nil 30 } 31 32 func NetPipe() (net.Conn, net.Conn) { 33 p1, p2 := net.Pipe() 34 return &pipe{p1}, &pipe{p2} 35 } 36 37 var _ net.Conn = (*pipe)(nil)