Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/kubo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b55cf12ba5f3
Choose a base ref
...
head repository: ipfs/kubo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 61cde12364ba
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Aug 28, 2015

  1. Refactor FullMeshLinked and ConnectAll()

    License: MIT
    Signed-off-by: rht <rhtbot@gmail.com>
    rht committed Aug 28, 2015
    Copy the full SHA
    63c7741 View commit details
  2. Merge pull request #1617 from rht/rm-full-mesh-linked

    Refactor FullMeshLinked and ConnectAll()
    jbenet committed Aug 28, 2015
    Copy the full SHA
    61cde12 View commit details
Showing with 7 additions and 19 deletions.
  1. +1 −0 p2p/net/mock/interface.go
  2. +2 −8 p2p/net/mock/mock.go
  3. +1 −1 p2p/net/mock/mock_net.go
  4. +3 −10 p2p/net/mock/mock_notif_test.go
1 change: 1 addition & 0 deletions p2p/net/mock/interface.go
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ type Mocknet interface {
DisconnectPeers(peer.ID, peer.ID) error
DisconnectNets(inet.Network, inet.Network) error
LinkAll() error
ConnectAllButSelf() error
}

// LinkOptions are used to change aspects of the links.
10 changes: 2 additions & 8 deletions p2p/net/mock/mock.go
Original file line number Diff line number Diff line change
@@ -28,14 +28,8 @@ func FullMeshLinked(ctx context.Context, n int) (Mocknet, error) {
return nil, err
}

nets := m.Nets()
for _, n1 := range nets {
for _, n2 := range nets {
// yes, even self.
if _, err := m.LinkNets(n1, n2); err != nil {
return nil, err
}
}
if err := m.LinkAll(); err != nil {
return nil, err
}

return m, nil
2 changes: 1 addition & 1 deletion p2p/net/mock/mock_net.go
Original file line number Diff line number Diff line change
@@ -296,7 +296,7 @@ func (mn *mocknet) removeLink(l *link) {
delete(*mn.linksMapGet(n2.peer, n1.peer), l)
}

func (mn *mocknet) ConnectAll() error {
func (mn *mocknet) ConnectAllButSelf() error {
nets := mn.Nets()
for _, n1 := range nets {
for _, n2 := range nets {
13 changes: 3 additions & 10 deletions p2p/net/mock/mock_notif_test.go
Original file line number Diff line number Diff line change
@@ -28,16 +28,9 @@ func TestNotifications(t *testing.T) {
notifiees[i] = n
}

// connect all
for _, n1 := range nets {
for _, n2 := range nets {
if n1 == n2 {
continue
}
if _, err := mn.ConnectNets(n1, n2); err != nil {
t.Fatal(err)
}
}
// connect all but self
if err := mn.ConnectAllButSelf(); err != nil {
t.Fatal(err)
}

// test everyone got the correct connection opened calls