github.com/okex/exchain@v1.8.0/libs/tendermint/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  //  https://github.com/golang/go/commit/e2dd8ca946be884bb877e074a21727f1a685a706
    14  // lest we run into problems like
    15  //  https://github.com/tendermint/tendermint/issues/851
    16  // so for go versions < Go1.10 use our custom net.Conn creator
    17  // that doesn't return an `Unimplemented error` for net.Conn.
    18  // Before https://github.com/tendermint/tendermint/commit/49faa79bdce5663894b3febbf4955fb1d172df04
    19  // we hadn't cared about errors from SetDeadline so swallow them up anyways.
    20  type pipe struct {
    21  	net.Conn
    22  }
    23  
    24  func (p *pipe) SetDeadline(t time.Time) error {
    25  	return nil
    26  }
    27  
    28  func NetPipe() (net.Conn, net.Conn) {
    29  	p1, p2 := net.Pipe()
    30  	return &pipe{p1}, &pipe{p2}
    31  }
    32  
    33  var _ net.Conn = (*pipe)(nil)