mirror of
https://github.com/status-im/status-go.git
synced 2025-01-23 05:00:35 +00:00
40359f9c1b
* Adding wakunode module * Adding wakuv2 fleet files * Add waku fleets to update-fleet-config script * Adding config items for waku v2 * Conditionally start waku v2 node depending on config * Adapting common code to use go-waku * Setting log level to info * update dependencies * update fleet config to use WakuNodes instead of BootNodes * send and receive messages * use hash returned when publishing a message * add waku store protocol * trigger signal after receiving store messages * exclude linting rule SA1019 to check deprecated packages
64 lines
1.1 KiB
Go
64 lines
1.1 KiB
Go
package peerstream_multiplex
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/libp2p/go-libp2p-core/mux"
|
|
mp "github.com/libp2p/go-mplex"
|
|
)
|
|
|
|
// stream implements mux.MuxedStream over mplex.Stream.
|
|
type stream mp.Stream
|
|
|
|
func (s *stream) Read(b []byte) (n int, err error) {
|
|
n, err = s.mplex().Read(b)
|
|
if err == mp.ErrStreamReset {
|
|
err = mux.ErrReset
|
|
}
|
|
|
|
return n, err
|
|
}
|
|
|
|
func (s *stream) Write(b []byte) (n int, err error) {
|
|
n, err = s.mplex().Write(b)
|
|
if err == mp.ErrStreamReset {
|
|
err = mux.ErrReset
|
|
}
|
|
|
|
return n, err
|
|
}
|
|
|
|
func (s *stream) Close() error {
|
|
return s.mplex().Close()
|
|
}
|
|
|
|
func (s *stream) CloseWrite() error {
|
|
return s.mplex().CloseWrite()
|
|
}
|
|
|
|
func (s *stream) CloseRead() error {
|
|
return s.mplex().CloseRead()
|
|
}
|
|
|
|
func (s *stream) Reset() error {
|
|
return s.mplex().Reset()
|
|
}
|
|
|
|
func (s *stream) SetDeadline(t time.Time) error {
|
|
return s.mplex().SetDeadline(t)
|
|
}
|
|
|
|
func (s *stream) SetReadDeadline(t time.Time) error {
|
|
return s.mplex().SetReadDeadline(t)
|
|
}
|
|
|
|
func (s *stream) SetWriteDeadline(t time.Time) error {
|
|
return s.mplex().SetWriteDeadline(t)
|
|
}
|
|
|
|
func (s *stream) mplex() *mp.Stream {
|
|
return (*mp.Stream)(s)
|
|
}
|
|
|
|
var _ mux.MuxedStream = &stream{}
|