jbenet/go-ipfs — pull request #272 by maybebtc (2014-11-05 12:59:24+00:00)
Title: add context to DialPeer interface

@jbenet

I added `context.Context` to the `DialPeer(...)` interface method to preserve bitswap's API contract (that `bitswap.GetBlock` will return when the parent cancels its context). In the process, updated signatures throughout `net` to support the change.

Down in the swarm, discovered that `Swarm.Dial` ignores the caller's context and instead passes it's own into the `net.conn.Dialer`. Since the function is being called in the _context_ of the caller, the correct behavior is for swarm to pass the caller's context. Made this change in 7a2805e549783e976a1b048736ed007f8e2a8384.

@jbenet Are there any side effects to worry about?

I was excited to follow these calls down the stack. The `net` layer is in pretty good shape, and will continue to improve as the system matures and we discover useful conventions for large-scale concurrent design.