Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Notifications #645

Merged
merged 4 commits into from
Jan 24, 2015
Merged

Network Notifications #645

merged 4 commits into from
Jan 24, 2015

Conversation

jbenet
Copy link
Member

@jbenet jbenet commented Jan 24, 2015

This PR introduces network notifications. These are
typesafe (with the Notifiee pattern) and well scoped
in their own notification-responder "objects". (I say
"objects" because many times they're just another obj
casted)

The network notifications interface is:

// Notifiee is an interface for an object wishing to receive
// notifications from a Network.
type Notifiee interface {
  Connected(Network, Conn)      // called when a connection opened
  Disconnected(Network, Conn)   // called when a connection closed
  OpenedStream(Network, Stream) // called when a stream opened
  ClosedStream(Network, Stream) // called when a stream closed

  // TODO
  // PeerConnected(Network, peer.ID)    // called when a peer connected
  // PeerDisconnected(Network, peer.ID) // called when a peer disconnected
}

@jbenet jbenet added the status/in-progress In progress label Jan 24, 2015
@@ -339,6 +339,24 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
return "", nil
}

// Connected/Disconnected warns bitswap about peer connections
func (bs *bitswap) PeerConnected(p peer.ID) {
// TODO: add to clientWorker??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

jbenet added a commit that referenced this pull request Jan 24, 2015
@jbenet jbenet merged commit eb79b1b into master Jan 24, 2015
@jbenet jbenet removed the status/in-progress In progress label Jan 24, 2015
@jbenet jbenet deleted the net-notif branch January 24, 2015 18:25
@jbenet
Copy link
Member Author

jbenet commented Jan 24, 2015

cc @whyrusleeping take a look at these notifications

// TODO: add to clientWorker??

peers := make(chan peer.ID)
err := bs.sendWantlistToPeers(context.TODO(), peers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will hang. It reads on the channel, which you dont fill until after the call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants