first pass notes

This commit is contained in:
Mantas Vidutis 2018-12-11 09:20:12 -08:00 committed by vyzo
parent 88d35ae193
commit e0e0420595
6 changed files with 10 additions and 9 deletions

View File

@ -270,7 +270,7 @@ func (d *Daemon) doStreamHandler(req *pb.Request) *pb.Response {
if !ok {
d.host.SetStreamHandler(p, d.handleStream)
}
log.Debugf("set stream handler: %s -> %s", sp, maddr)
log.Debugf("set stream handler: %s -> %s", sp, maddr.String())
d.handlers[p] = maddr
}

View File

@ -33,7 +33,7 @@ type Daemon struct {
handlers map[proto.ID]ma.Multiaddr
}
func NewDaemon(ctx context.Context, maddr ma.Multiaddr, opts ...libp2p.Option) (*Daemon, error) {
func NewDaemon(ctx context.Context, maddr ma.Multiaddr, opts ...libp2p.Option) (*Daemon, error) {
h, err := libp2p.New(ctx, opts...)
if err != nil {
return nil, err

6
dht.go
View File

@ -5,11 +5,11 @@ import (
pb "github.com/libp2p/go-libp2p-daemon/pb"
crypto "github.com/libp2p/go-libp2p-crypto"
pstore "github.com/libp2p/go-libp2p-peerstore"
dht "github.com/libp2p/go-libp2p-kad-dht"
cid "github.com/ipfs/go-cid"
crypto "github.com/libp2p/go-libp2p-crypto"
dht "github.com/libp2p/go-libp2p-kad-dht"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
)
func (d *Daemon) doDHT(req *pb.Request) (*pb.Response, <-chan *pb.DHTResponse, func()) {

View File

@ -4,14 +4,15 @@ import (
"bytes"
"encoding/binary"
"fmt"
"io"
"net"
ggio "github.com/gogo/protobuf/io"
"github.com/gogo/protobuf/proto"
pb "github.com/libp2p/go-libp2p-daemon/pb"
"github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/multiformats/go-multiaddr-net"
"io"
"net"
)
// StreamInfo wraps the protobuf structure with friendlier types.

View File

@ -77,7 +77,7 @@ func main() {
opts = append(opts, libp2p.NATPortMap())
}
d, err := p2pd.NewDaemon(context.Background(), *maddr, opts...)
d, err := p2pd.NewDaemon(context.Background(), maddr, opts...)
if err != nil {
log.Fatal(err)
}

View File

@ -1,13 +1,13 @@
package p2pd
import (
"github.com/multiformats/go-multiaddr-net"
"io"
"net"
"sync"
ggio "github.com/gogo/protobuf/io"
inet "github.com/libp2p/go-libp2p-net"
"github.com/multiformats/go-multiaddr-net"
)
func (d *Daemon) doStreamPipe(c net.Conn, s inet.Stream) {