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
p2p
go-p2p-kad-dht
Commits
fc3558cc
Unverified
Commit
fc3558cc
authored
Jul 30, 2020
by
Raúl Kripalani
Committed by
GitHub
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade deps + uvarint delimited writer/reader. (#684)
parent
81b0285d
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
302 additions
and
37 deletions
+302
-37
dht_filters_test.go
dht_filters_test.go
+3
-0
dht_net.go
dht_net.go
+3
-4
ext_test.go
ext_test.go
+13
-12
go.mod
go.mod
+18
-18
go.sum
go.sum
+265
-3
No files found.
dht_filters_test.go
View file @
fc3558cc
...
...
@@ -34,6 +34,9 @@ type mockConn struct {
remote
peer
.
AddrInfo
}
var
_
network
.
Conn
=
(
*
mockConn
)(
nil
)
func
(
m
*
mockConn
)
ID
()
string
{
return
"0"
}
func
(
m
*
mockConn
)
Close
()
error
{
return
nil
}
func
(
m
*
mockConn
)
NewStream
()
(
network
.
Stream
,
error
)
{
return
nil
,
nil
}
func
(
m
*
mockConn
)
GetStreams
()
[]
network
.
Stream
{
return
[]
network
.
Stream
{}
}
...
...
dht_net.go
View file @
fc3558cc
...
...
@@ -11,12 +11,11 @@ import (
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-msgio/protoio"
"github.com/libp2p/go-libp2p-kad-dht/metrics"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
ggio
"github.com/gogo/protobuf/io"
"github.com/libp2p/go-msgio"
"go.opencensus.io/stats"
"go.opencensus.io/tag"
...
...
@@ -34,7 +33,7 @@ var ErrReadTimeout = fmt.Errorf("timed out reading response")
// packet for every single write.
type
bufferedDelimitedWriter
struct
{
*
bufio
.
Writer
gg
io
.
WriteCloser
proto
io
.
WriteCloser
}
var
writerPool
=
sync
.
Pool
{
...
...
@@ -42,7 +41,7 @@ var writerPool = sync.Pool{
w
:=
bufio
.
NewWriter
(
nil
)
return
&
bufferedDelimitedWriter
{
Writer
:
w
,
WriteCloser
:
gg
io
.
NewDelimitedWriter
(
w
),
WriteCloser
:
proto
io
.
NewDelimitedWriter
(
w
),
}
},
}
...
...
ext_test.go
View file @
fc3558cc
...
...
@@ -12,13 +12,14 @@ import (
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/libp2p/go-libp2p-core/routing"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
record
"github.com/libp2p/go-libp2p-record"
swarmt
"github.com/libp2p/go-libp2p-swarm/testing"
bhost
"github.com/libp2p/go-libp2p/p2p/host/basic"
mocknet
"github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/libp2p/go-msgio/protoio"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
ggio
"github.com/gogo/protobuf/io"
u
"github.com/ipfs/go-ipfs-util"
)
...
...
@@ -144,8 +145,8 @@ func TestGetFailures(t *testing.T) {
host2
.
SetStreamHandler
(
proto
,
func
(
s
network
.
Stream
)
{
defer
s
.
Close
()
pbr
:=
gg
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
gg
io
.
NewDelimitedWriter
(
s
)
pbr
:=
proto
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
proto
io
.
NewDelimitedWriter
(
s
)
pmes
:=
new
(
pb
.
Message
)
if
err
:=
pbr
.
ReadMsg
(
pmes
);
err
!=
nil
{
...
...
@@ -199,8 +200,8 @@ func TestGetFailures(t *testing.T) {
}
defer
s
.
Close
()
pbr
:=
gg
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
gg
io
.
NewDelimitedWriter
(
s
)
pbr
:=
proto
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
proto
io
.
NewDelimitedWriter
(
s
)
if
err
:=
pbw
.
WriteMsg
(
&
req
);
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -250,8 +251,8 @@ func TestNotFound(t *testing.T) {
host
.
SetStreamHandler
(
proto
,
func
(
s
network
.
Stream
)
{
defer
s
.
Close
()
pbr
:=
gg
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
gg
io
.
NewDelimitedWriter
(
s
)
pbr
:=
proto
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
proto
io
.
NewDelimitedWriter
(
s
)
pmes
:=
new
(
pb
.
Message
)
if
err
:=
pbr
.
ReadMsg
(
pmes
);
err
!=
nil
{
...
...
@@ -347,8 +348,8 @@ func TestLessThanKResponses(t *testing.T) {
host
.
SetStreamHandler
(
proto
,
func
(
s
network
.
Stream
)
{
defer
s
.
Close
()
pbr
:=
gg
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
gg
io
.
NewDelimitedWriter
(
s
)
pbr
:=
proto
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
proto
io
.
NewDelimitedWriter
(
s
)
pmes
:=
new
(
pb
.
Message
)
if
err
:=
pbr
.
ReadMsg
(
pmes
);
err
!=
nil
{
...
...
@@ -416,8 +417,8 @@ func TestMultipleQueries(t *testing.T) {
hosts
[
1
]
.
SetStreamHandler
(
proto
,
func
(
s
network
.
Stream
)
{
defer
s
.
Close
()
pbr
:=
gg
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
gg
io
.
NewDelimitedWriter
(
s
)
pbr
:=
proto
io
.
NewDelimitedReader
(
s
,
network
.
MessageSizeMax
)
pbw
:=
proto
io
.
NewDelimitedWriter
(
s
)
pmes
:=
new
(
pb
.
Message
)
if
err
:=
pbr
.
ReadMsg
(
pmes
);
err
!=
nil
{
...
...
go.mod
View file @
fc3558cc
...
...
@@ -4,35 +4,35 @@ go 1.14
require (
github.com/gogo/protobuf
v1.3.1
github.com/google/gopacket
v1.1.1
7
github.com/google/gopacket
v1.1.1
8
github.com/google/uuid
v1.1.1
github.com/hashicorp/go-multierror
v1.1.0
github.com/hashicorp/golang-lru
v0.5.4
github.com/ipfs/go-cid
v0.0.
5
github.com/ipfs/go-cid
v0.0.
7
github.com/ipfs/go-datastore
v0.4.4
github.com/ipfs/go-detect-race
v0.0.1
github.com/ipfs/go-ipfs-util
v0.0.
1
github.com/ipfs/go-ipfs-util
v0.0.
2
github.com/ipfs/go-ipns
v0.0.2
github.com/ipfs/go-log
v1.0.4
github.com/jbenet/goprocess
v0.1.4
github.com/libp2p/go-eventbus
v0.
1.0
github.com/libp2p/go-libp2p
v0.
8.2
github.com/libp2p/go-libp2p-core
v0.
5.4
github.com/libp2p/go-eventbus
v0.
2.1
github.com/libp2p/go-libp2p
v0.
10.0
github.com/libp2p/go-libp2p-core
v0.
6.1
github.com/libp2p/go-libp2p-kbucket
v0.4.2
github.com/libp2p/go-libp2p-peerstore
v0.2.
4
github.com/libp2p/go-libp2p-record
v0.1.
2
github.com/libp2p/go-libp2p-peerstore
v0.2.
6
github.com/libp2p/go-libp2p-record
v0.1.
3
github.com/libp2p/go-libp2p-routing-helpers
v0.2.3
github.com/libp2p/go-libp2p-swarm
v0.2.
3
github.com/libp2p/go-libp2p-testing
v0.1.
1
github.com/libp2p/go-msgio
v0.0.
4
github.com/libp2p/go-netroute
v0.1.
2
github.com/libp2p/go-libp2p-swarm
v0.2.
8
github.com/libp2p/go-libp2p-testing
v0.1.
2-0.20200422005655-8775583591d8
github.com/libp2p/go-msgio
v0.0.
6
github.com/libp2p/go-netroute
v0.1.
3
github.com/multiformats/go-base32
v0.0.3
github.com/multiformats/go-multiaddr
v0.2.
1
github.com/multiformats/go-multiaddr
v0.2.
2
github.com/multiformats/go-multiaddr-net
v0.1.5
github.com/multiformats/go-multihash
v0.0.1
3
github.com/multiformats/go-multistream
v0.1.
1
github.com/stretchr/testify
v1.
5
.1
github.com/multiformats/go-multihash
v0.0.1
4
github.com/multiformats/go-multistream
v0.1.
2
github.com/stretchr/testify
v1.
6
.1
github.com/whyrusleeping/go-keyspace
v0.0.0-20160322163242-5b898ac5add1
go.opencensus.io
v0.22.
3
go.uber.org/zap
v1.1
4.1
go.opencensus.io
v0.22.
4
go.uber.org/zap
v1.1
5.0
)
go.sum
View file @
fc3558cc
This diff is collapsed.
Click to expand it.
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