Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
f18bbde3
Commit
f18bbde3
authored
Dec 16, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: StreamHandlerMap + protocol ids
parent
b039ebce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
net/interface.go
net/interface.go
+9
-1
net/mux_test.go
net/mux_test.go
+1
-1
No files found.
net/interface.go
View file @
f18bbde3
...
...
@@ -11,6 +11,12 @@ import (
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
)
const
(
ProtocolBitswap
=
"/ipfs/bitswap"
ProtocolDHT
=
"/ipfs/dht"
ProtocolDiag
=
"/ipfs/diagnostics"
)
// Stream represents a bidirectional channel between two agents in
// the IPFS network. "agent" is as granular as desired, potentially
// being a "request -> reply" pair, or whole protocols.
...
...
@@ -28,6 +34,8 @@ type Stream interface {
// incoming streams must implement.
type
StreamHandler
func
(
Stream
)
type
StreamHandlerMap
map
[
string
]
StreamHandler
// Conn is a connection to a remote peer. It multiplexes streams.
// Usually there is no need to use a Conn directly, but it may
// be useful to get information about the peer on the other side:
...
...
@@ -58,7 +66,7 @@ type Conn interface {
// do not modify it once the network is using it.
type
Mux
struct
{
Default
StreamHandler
// handles unknown protocols.
Handlers
map
[
string
]
StreamHandler
Handlers
StreamHandler
Map
}
// Network is the interface IPFS uses for connecting to the world.
...
...
net/mux_test.go
View file @
f18bbde3
...
...
@@ -34,7 +34,7 @@ func TestHandler(t *testing.T) {
}
}
m
:=
Mux
{
Handlers
:
map
[
string
]
StreamHandler
{}}
m
:=
Mux
{
Handlers
:
StreamHandler
Map
{}}
m
.
Default
=
h
(
"default"
)
m
.
Handlers
[
"dht"
]
=
h
(
"bitswap"
)
// m.Handlers["ipfs"] = h("bitswap") // default!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment