first pass notes
This commit is contained in:
parent
88d35ae193
commit
e0e0420595
2
conn.go
2
conn.go
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
6
dht.go
|
@ -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()) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue