Merge pull request #7 from libp2p/fix/stream-handler

fix stream handler
This commit is contained in:
Steven Allen 2018-09-21 17:36:57 +00:00 committed by GitHub
commit 644b1a8dfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -36,6 +36,8 @@ func (d *Daemon) handleConn(c net.Conn) {
return return
} }
log.Debugf("request: %d [%s]", *req.Type, req.Type.String())
switch *req.Type { switch *req.Type {
case pb.Request_IDENTIFY: case pb.Request_IDENTIFY:
res := d.doIdentify(&req) res := d.doIdentify(&req)
@ -174,13 +176,13 @@ func (d *Daemon) doStreamHandler(req *pb.Request) *pb.Response {
defer d.mx.Unlock() defer d.mx.Unlock()
path := *req.StreamHandler.Path path := *req.StreamHandler.Path
for sp := range req.StreamHandler.Proto { for _, sp := range req.StreamHandler.Proto {
p := proto.ID(sp) p := proto.ID(sp)
_, ok := d.handlers[p] _, ok := d.handlers[p]
if !ok { if !ok {
d.host.SetStreamHandler(p, d.handleStream) d.host.SetStreamHandler(p, d.handleStream)
} }
log.Debugf("set stream handler: %s -> %s", p, path) log.Debugf("set stream handler: %s -> %s", sp, path)
d.handlers[p] = path d.handlers[p] = path
} }