mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 21:07:45 +08:00
swarm fixes
This commit is contained in:
parent
b5b4390ca4
commit
31a3c4497a
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSimultOpen(t *testing.T) {
|
||||
t.Skip("skipping for another test")
|
||||
// t.Skip("skipping for another test")
|
||||
|
||||
addrs := []string{
|
||||
"/ip4/127.0.0.1/tcp/1244",
|
||||
@ -49,9 +49,9 @@ func TestSimultOpen(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSimultOpenMany(t *testing.T) {
|
||||
t.Skip("very very slow")
|
||||
// t.Skip("very very slow")
|
||||
|
||||
many := 500
|
||||
many := 10
|
||||
addrs := []string{}
|
||||
for i := 2200; i < (2200 + many); i++ {
|
||||
s := fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", i)
|
||||
@ -65,7 +65,7 @@ func TestSimultOpenFewStress(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
t.Skip("skipping for another test")
|
||||
// t.Skip("skipping for another test")
|
||||
|
||||
num := 10
|
||||
// num := 100
|
||||
|
||||
@ -70,6 +70,14 @@ func (s *Swarm) SetStreamHandler(handler StreamHandler) {
|
||||
|
||||
// NewStreamWithPeer creates a new stream on any available connection to p
|
||||
func (s *Swarm) NewStreamWithPeer(p peer.Peer) (*Stream, error) {
|
||||
|
||||
// if we have no connections, try connecting.
|
||||
if len(s.ConnectionsToPeer(p)) == 0 {
|
||||
if _, err := s.Dial(p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
st, err := s.swarm.NewStreamWithGroup(p)
|
||||
return wrapStream(st), err
|
||||
}
|
||||
|
||||
@ -14,11 +14,11 @@ import (
|
||||
// a Conn is a simple wrapper around a ps.Conn that also exposes
|
||||
// some of the methods from the underlying conn.Conn.
|
||||
// There's **five** "layers" to each connection:
|
||||
// - 0. the net.Conn - underlying net.Conn (TCP/UDP/UTP/etc)
|
||||
// - 1. the manet.Conn - provides multiaddr friendly Conn
|
||||
// - 2. the conn.Conn - provides Peer friendly Conn (inc Secure channel)
|
||||
// - 3. the peerstream.Conn - provides peerstream / spdysptream happiness
|
||||
// - 4. the Conn - abstracts everyting out, exposing only key parts of underlying layers
|
||||
// * 0. the net.Conn - underlying net.Conn (TCP/UDP/UTP/etc)
|
||||
// * 1. the manet.Conn - provides multiaddr friendly Conn
|
||||
// * 2. the conn.Conn - provides Peer friendly Conn (inc Secure channel)
|
||||
// * 3. the peerstream.Conn - provides peerstream / spdysptream happiness
|
||||
// * 4. the Conn - abstracts everyting out, exposing only key parts of underlying layers
|
||||
// (I know, this is kinda crazy. it's more historical than a good design. though the
|
||||
// layers do build up pieces of functionality. and they're all just io.RW :) )
|
||||
type Conn ps.Conn
|
||||
|
||||
@ -18,12 +18,15 @@ func (s *Swarm) listen(addrs []ma.Multiaddr) error {
|
||||
for i, addr := range addrs {
|
||||
err := s.setupListener(addr)
|
||||
if err != nil {
|
||||
if retErr.Errors == nil {
|
||||
retErr.Errors = make([]error, len(addrs))
|
||||
}
|
||||
retErr.Errors[i] = err
|
||||
log.Errorf("Failed to listen on: %s - %s", addr, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(retErr.Errors) > 0 {
|
||||
if retErr.Errors != nil {
|
||||
return retErr
|
||||
}
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user