Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
077aae47
Commit
077aae47
authored
8 years ago
by
Jeromy
Browse files
Options
Download
Email Patches
Plain Diff
make bandwidth metrics optional
parent
647d20ae
master
2018-Q4-OKR
docs-improvements
feat/p2p-multiaddr
feat/pnet/working3
feat/protobuf
feat/relay-integrate
feat/udp
feature/standardize-readme
fix/473
fix/no-custom-field
fix/reset-ping-stream
fix/revert-correct-external-addr
gx/update-jccl6u
gx/update-nza0mn
jenkinsfile
kevina/fix-go-vet
multistream-ping
punching
revert-276-update-go-detect-race
v6.0.23
v6.0.22
v6.0.21
v6.0.20
v6.0.19
v6.0.18
v6.0.17
v6.0.16
v6.0.15
v6.0.14
v6.0.13
v6.0.12
v6.0.11
v6.0.10
v6.0.9
v6.0.8
v6.0.7
v6.0.6
v6.0.5
v6.0.4
v6.0.3
v6.0.2
v6.0.1
v6.0.0
v5.0.21
v5.0.20
v5.0.19
v5.0.18
v5.0.17
v5.0.16
v5.0.15
v5.0.14
v5.0.13
v5.0.12
v5.0.11
v5.0.10
v5.0.9
v5.0.8
v5.0.7
v5.0.6
v5.0.5
v5.0.4
v5.0.3
v5.0.2
v5.0.1
v5.0.0
v4.5.5
v4.5.4
v4.5.3
v4.5.2
v4.5.1
v4.5.0
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.12
v4.3.11
v4.3.10
v4.3.9
v4.3.8
v4.3.7
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.0
v4.1.0
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
p2p/host/basic/basic_host.go
+12
-5
p2p/host/basic/basic_host.go
p2p/host/routed/routed.go
+1
-6
p2p/host/routed/routed.go
p2p/protocol/identify/id.go
+8
-4
p2p/protocol/identify/id.go
package.json
+2
-2
package.json
with
23 additions
and
17 deletions
+23
-17
p2p/host/basic/basic_host.go
View file @
077aae47
...
...
@@ -58,7 +58,6 @@ func New(net inet.Network, opts ...interface{}) *BasicHost {
h
:=
&
BasicHost
{
network
:
net
,
mux
:
msmux
.
NewMultistreamMuxer
(),
bwc
:
metrics
.
NewBandwidthCounter
(),
}
h
.
proc
=
goprocess
.
WithTeardown
(
func
()
error
{
...
...
@@ -90,6 +89,8 @@ func New(net inet.Network, opts ...interface{}) *BasicHost {
}
}
h
.
ids
.
Reporter
=
h
.
bwc
net
.
SetConnHandler
(
h
.
newConnHandler
)
net
.
SetStreamHandler
(
h
.
newStreamHandler
)
...
...
@@ -217,7 +218,11 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I
s
.
SetProtocol
(
selpid
)
h
.
Peerstore
()
.
AddProtocols
(
p
,
selected
)
return
mstream
.
WrapStream
(
s
,
h
.
bwc
),
nil
if
h
.
bwc
!=
nil
{
s
=
mstream
.
WrapStream
(
s
,
h
.
bwc
)
}
return
s
,
nil
}
func
pidsToStrings
(
pids
[]
protocol
.
ID
)
[]
string
{
...
...
@@ -250,11 +255,13 @@ func (h *BasicHost) newStream(ctx context.Context, p peer.ID, pid protocol.ID) (
s
.
SetProtocol
(
pid
)
logStream
:=
mstream
.
WrapStream
(
s
,
h
.
bwc
)
if
h
.
bwc
!=
nil
{
s
=
mstream
.
WrapStream
(
s
,
h
.
bwc
)
}
lzcon
:=
msmux
.
NewMSSelect
(
logStream
,
string
(
pid
))
lzcon
:=
msmux
.
NewMSSelect
(
s
,
string
(
pid
))
return
&
streamWrapper
{
Stream
:
logStream
,
Stream
:
s
,
rw
:
lzcon
,
},
nil
}
...
...
This diff is collapsed.
Click to expand it.
p2p/host/routed/routed.go
View file @
077aae47
...
...
@@ -9,7 +9,6 @@ import (
logging
"github.com/ipfs/go-log"
lgbl
"github.com/libp2p/go-libp2p-loggables"
metrics
"github.com/libp2p/go-libp2p-metrics"
inet
"github.com/libp2p/go-libp2p-net"
peer
"github.com/libp2p/go-libp2p-peer"
pstore
"github.com/libp2p/go-libp2p-peerstore"
...
...
@@ -18,7 +17,7 @@ import (
msmux
"github.com/whyrusleeping/go-multistream"
)
var
log
=
logging
.
Logger
(
"
github.com/libp2p/go-libp2p/p2p/host/
routed"
)
var
log
=
logging
.
Logger
(
"routed
host
"
)
// AddressTTL is the expiry time for our addresses.
// We expire them quickly.
...
...
@@ -126,8 +125,4 @@ func (rh *RoutedHost) Close() error {
return
rh
.
host
.
Close
()
}
func
(
rh
*
RoutedHost
)
GetBandwidthReporter
()
metrics
.
Reporter
{
return
rh
.
host
.
GetBandwidthReporter
()
}
var
_
(
host
.
Host
)
=
(
*
RoutedHost
)(
nil
)
This diff is collapsed.
Click to expand it.
p2p/protocol/identify/id.go
View file @
077aae47
...
...
@@ -13,6 +13,7 @@ import (
ic
"github.com/libp2p/go-libp2p-crypto"
host
"github.com/libp2p/go-libp2p-host"
lgbl
"github.com/libp2p/go-libp2p-loggables"
metrics
"github.com/libp2p/go-libp2p-metrics"
mstream
"github.com/libp2p/go-libp2p-metrics/stream"
inet
"github.com/libp2p/go-libp2p-net"
peer
"github.com/libp2p/go-libp2p-peer"
...
...
@@ -42,6 +43,7 @@ const ClientVersion = "go-libp2p/3.3.4"
type
IDService
struct
{
Host
host
.
Host
Reporter
metrics
.
Reporter
// connections undergoing identification
// for wait purposes
currid
map
[
inet
.
Conn
]
chan
struct
{}
...
...
@@ -91,8 +93,9 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
s
.
SetProtocol
(
ID
)
bwc
:=
ids
.
Host
.
GetBandwidthReporter
()
s
=
mstream
.
WrapStream
(
s
,
bwc
)
if
ids
.
Reporter
!=
nil
{
s
=
mstream
.
WrapStream
(
s
,
ids
.
Reporter
)
}
// ok give the response to our handler.
if
err
:=
msmux
.
SelectProtoOrFail
(
ID
,
s
);
err
!=
nil
{
...
...
@@ -118,8 +121,9 @@ func (ids *IDService) RequestHandler(s inet.Stream) {
defer
s
.
Close
()
c
:=
s
.
Conn
()
bwc
:=
ids
.
Host
.
GetBandwidthReporter
()
s
=
mstream
.
WrapStream
(
s
,
bwc
)
if
ids
.
Reporter
!=
nil
{
s
=
mstream
.
WrapStream
(
s
,
ids
.
Reporter
)
}
w
:=
ggio
.
NewDelimitedWriter
(
s
)
mes
:=
pb
.
Identify
{}
...
...
This diff is collapsed.
Click to expand it.
package.json
View file @
077aae47
...
...
@@ -211,9 +211,9 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
U5qKZsCG1Wg38jwg8XezBdc3fBGMMZjM7YFMAhunC1Yh
"
,
"hash"
:
"Qm
b6UFbVu1grhv5o5KnouvtZ6cqdrjXj6zLejAHWunxgCt
"
,
"name"
:
"go-libp2p-host"
,
"version"
:
"1.
2
.0"
"version"
:
"1.
3
.0"
},
{
"author"
:
"whyrusleeping"
,
...
...
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
Menu
Projects
Groups
Snippets
Help