Skip to content
GitLab
Menu
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
5b9cd671
Commit
5b9cd671
authored
Jul 27, 2016
by
Jeromy Johnson
Committed by
GitHub
Jul 27, 2016
Browse files
Merge pull request #77 from John-Steidley/gosimple
Ran gosimple (github.com/dominikh/go-simple) on go-libp2p
parents
b32016eb
5c8093b0
Changes
9
Show whitespace changes
Inline
Side-by-side
p2p/discovery/mdns.go
View file @
5b9cd671
...
@@ -110,9 +110,7 @@ func (m *mdnsService) Close() error {
...
@@ -110,9 +110,7 @@ func (m *mdnsService) Close() error {
func
(
m
*
mdnsService
)
pollForEntries
()
{
func
(
m
*
mdnsService
)
pollForEntries
()
{
ticker
:=
time
.
NewTicker
(
m
.
interval
)
ticker
:=
time
.
NewTicker
(
m
.
interval
)
for
{
for
range
ticker
.
C
{
select
{
case
<-
ticker
.
C
:
entriesCh
:=
make
(
chan
*
mdns
.
ServiceEntry
,
16
)
entriesCh
:=
make
(
chan
*
mdns
.
ServiceEntry
,
16
)
go
func
()
{
go
func
()
{
for
entry
:=
range
entriesCh
{
for
entry
:=
range
entriesCh
{
...
@@ -132,7 +130,6 @@ func (m *mdnsService) pollForEntries() {
...
@@ -132,7 +130,6 @@ func (m *mdnsService) pollForEntries() {
}
}
close
(
entriesCh
)
close
(
entriesCh
)
}
}
}
}
}
func
(
m
*
mdnsService
)
handleEntry
(
e
*
mdns
.
ServiceEntry
)
{
func
(
m
*
mdnsService
)
handleEntry
(
e
*
mdns
.
ServiceEntry
)
{
...
...
p2p/nat/nat.go
View file @
5b9cd671
...
@@ -208,7 +208,7 @@ func (m *mapping) ExternalAddr() (ma.Multiaddr, error) {
...
@@ -208,7 +208,7 @@ func (m *mapping) ExternalAddr() (ma.Multiaddr, error) {
ctime
:=
m
.
cacheTime
ctime
:=
m
.
cacheTime
cval
:=
m
.
cached
cval
:=
m
.
cached
m
.
cacheLk
.
Unlock
()
m
.
cacheLk
.
Unlock
()
if
time
.
Now
()
.
Sub
(
ctime
)
<
CacheTime
{
if
time
.
Since
(
ctime
)
<
CacheTime
{
return
cval
,
nil
return
cval
,
nil
}
}
...
...
p2p/net/conn/dial.go
View file @
5b9cd671
...
@@ -86,7 +86,7 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
...
@@ -86,7 +86,7 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
return
return
}
}
if
d
.
PrivateKey
==
nil
||
EncryptConnections
==
false
{
if
d
.
PrivateKey
==
nil
||
!
EncryptConnections
{
log
.
Warning
(
"dialer %s dialing INSECURELY %s at %s!"
,
d
,
remote
,
raddr
)
log
.
Warning
(
"dialer %s dialing INSECURELY %s at %s!"
,
d
,
remote
,
raddr
)
connOut
=
c
connOut
=
c
return
return
...
...
p2p/net/conn/dial_test.go
View file @
5b9cd671
...
@@ -514,7 +514,7 @@ func TestConcurrentAccept(t *testing.T) {
...
@@ -514,7 +514,7 @@ func TestConcurrentAccept(t *testing.T) {
}
}
limit
:=
delay
*
time
.
Duration
(
n
)
limit
:=
delay
*
time
.
Duration
(
n
)
took
:=
time
.
Now
()
.
Sub
(
before
)
took
:=
time
.
Since
(
before
)
if
took
>
limit
{
if
took
>
limit
{
t
.
Fatal
(
"took too long!"
)
t
.
Fatal
(
"took too long!"
)
}
}
...
@@ -606,7 +606,7 @@ func TestConnectionTimeouts(t *testing.T) {
...
@@ -606,7 +606,7 @@ func TestConnectionTimeouts(t *testing.T) {
c
.
Close
()
c
.
Close
()
}
}
took
:=
time
.
Now
()
.
Sub
(
before
)
took
:=
time
.
Since
(
before
)
if
took
>
time
.
Second
*
5
{
if
took
>
time
.
Second
*
5
{
t
.
Fatal
(
"hanging dials shouldnt block good dials"
)
t
.
Fatal
(
"hanging dials shouldnt block good dials"
)
...
...
p2p/net/conn/listen.go
View file @
5b9cd671
...
@@ -93,7 +93,7 @@ func (l *listener) Accept() (net.Conn, error) {
...
@@ -93,7 +93,7 @@ func (l *listener) Accept() (net.Conn, error) {
return
nil
,
err
return
nil
,
err
}
}
if
l
.
privk
==
nil
||
EncryptConnections
==
false
{
if
l
.
privk
==
nil
||
!
EncryptConnections
{
log
.
Warning
(
"listener %s listening INSECURELY!"
,
l
)
log
.
Warning
(
"listener %s listening INSECURELY!"
,
l
)
return
c
,
nil
return
c
,
nil
}
}
...
...
p2p/net/swarm/dial_test.go
View file @
5b9cd671
...
@@ -187,7 +187,7 @@ func TestDialWait(t *testing.T) {
...
@@ -187,7 +187,7 @@ func TestDialWait(t *testing.T) {
}
else
{
}
else
{
t
.
Log
(
"correctly got error:"
,
err
)
t
.
Log
(
"correctly got error:"
,
err
)
}
}
duration
:=
time
.
Now
()
.
Sub
(
before
)
duration
:=
time
.
Since
(
before
)
dt
:=
s1
.
dialT
dt
:=
s1
.
dialT
if
duration
<
dt
*
dialAttempts
{
if
duration
<
dt
*
dialAttempts
{
...
@@ -451,7 +451,7 @@ func TestDialBackoffClears(t *testing.T) {
...
@@ -451,7 +451,7 @@ func TestDialBackoffClears(t *testing.T) {
}
else
{
}
else
{
t
.
Log
(
"correctly got error:"
,
err
)
t
.
Log
(
"correctly got error:"
,
err
)
}
}
duration
:=
time
.
Now
()
.
Sub
(
before
)
duration
:=
time
.
Since
(
before
)
dt
:=
s1
.
dialT
dt
:=
s1
.
dialT
if
duration
<
dt
*
dialAttempts
{
if
duration
<
dt
*
dialAttempts
{
...
...
p2p/net/swarm/swarm_net.go
View file @
5b9cd671
...
@@ -124,7 +124,7 @@ func (n *Network) InterfaceListenAddresses() ([]ma.Multiaddr, error) {
...
@@ -124,7 +124,7 @@ func (n *Network) InterfaceListenAddresses() ([]ma.Multiaddr, error) {
// For now only returns Connected || NotConnected. Expand into more later.
// For now only returns Connected || NotConnected. Expand into more later.
func
(
n
*
Network
)
Connectedness
(
p
peer
.
ID
)
inet
.
Connectedness
{
func
(
n
*
Network
)
Connectedness
(
p
peer
.
ID
)
inet
.
Connectedness
{
c
:=
n
.
Swarm
()
.
ConnectionsToPeer
(
p
)
c
:=
n
.
Swarm
()
.
ConnectionsToPeer
(
p
)
if
c
!=
nil
&&
len
(
c
)
>
0
{
if
len
(
c
)
>
0
{
return
inet
.
Connected
return
inet
.
Connected
}
}
return
inet
.
NotConnected
return
inet
.
NotConnected
...
...
p2p/protocol/ping/ping.go
View file @
5b9cd671
...
@@ -121,5 +121,5 @@ func ping(s inet.Stream) (time.Duration, error) {
...
@@ -121,5 +121,5 @@ func ping(s inet.Stream) (time.Duration, error) {
return
0
,
errors
.
New
(
"ping packet was incorrect!"
)
return
0
,
errors
.
New
(
"ping packet was incorrect!"
)
}
}
return
time
.
Now
()
.
Sub
(
before
),
nil
return
time
.
Since
(
before
),
nil
}
}
p2p/test/backpressure/backpressure_test.go
View file @
5b9cd671
...
@@ -318,7 +318,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
...
@@ -318,7 +318,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
receive
(
s
,
b
)
receive
(
s
,
b
)
roundsTotal
=
roundsTotal
+
b
roundsTotal
=
roundsTotal
+
b
}
}
roundsTime
:=
time
.
Now
()
.
Sub
(
roundsStart
)
roundsTime
:=
time
.
Since
(
roundsStart
)
// now read continously, while we measure stats.
// now read continously, while we measure stats.
stop
:=
make
(
chan
struct
{})
stop
:=
make
(
chan
struct
{})
...
@@ -341,7 +341,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
...
@@ -341,7 +341,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
contTotal
+=
n
contTotal
+=
n
}
}
stop
<-
struct
{}{}
stop
<-
struct
{}{}
contTime
:=
time
.
Now
()
.
Sub
(
contStart
)
contTime
:=
time
.
Since
(
contStart
)
// now compare! continuous should've been faster AND larger
// now compare! continuous should've been faster AND larger
if
roundsTime
<
contTime
{
if
roundsTime
<
contTime
{
...
...
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