Dmitry eeca435064 Add rendezvous implementation for discovery interface
Update vendor

Integrate rendezvous into status node

Add a test with failover using rendezvous

Use multiple servers in client

Use discovery V5 by default and test that node can be started with rendezvous discovet

Fix linter

Update rendezvous client to one with instrumented stream

Address feedback

Fix test with updated topic limits

Apply several suggestions

Change log to debug for request errors because we continue execution

Remove web3js after rebase

Update rendezvous package
2018-07-25 15:10:57 +03:00

38 lines
766 B
Go

package multistream
import (
"io"
"sync"
)
// lazyServerConn is an io.ReadWriteCloser adapter used for negotiating inbound
// streams (see NegotiateLazy).
//
// This is "lazy" because it doesn't wait for the write half to succeed before
// allowing us to read from the stream.
type lazyServerConn struct {
waitForHandshake sync.Once
werr error
con io.ReadWriteCloser
}
func (l *lazyServerConn) Write(b []byte) (int, error) {
l.waitForHandshake.Do(func() { panic("didn't initiate handshake") })
if l.werr != nil {
return 0, l.werr
}
return l.con.Write(b)
}
func (l *lazyServerConn) Read(b []byte) (int, error) {
if len(b) == 0 {
return 0, nil
}
return l.con.Read(b)
}
func (l *lazyServerConn) Close() error {
return l.con.Close()
}