github.com/vipernet-xyz/tendermint-core@v0.32.0/p2p/conn/conn_notgo110.go (about)

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