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-connmgr
Commits
bcbce348
Commit
bcbce348
authored
Apr 23, 2021
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix staticcheck
parent
0b84e304
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3 additions
and
8 deletions
+3
-8
bench_test.go
bench_test.go
+1
-1
connmgr.go
connmgr.go
+0
-2
connmgr_test.go
connmgr_test.go
+0
-2
decay.go
decay.go
+2
-3
No files found.
bench_test.go
View file @
bcbce348
...
...
@@ -9,7 +9,7 @@ import (
)
func
randomConns
(
tb
testing
.
TB
)
(
c
[
5000
]
network
.
Conn
)
{
for
i
,
_
:=
range
c
{
for
i
:=
range
c
{
c
[
i
]
=
randConn
(
tb
,
nil
)
}
return
c
...
...
connmgr.go
View file @
bcbce348
...
...
@@ -286,10 +286,8 @@ func (cm *BasicConnMgr) trim() {
}
// do the actual trim.
defer
log
.
EventBegin
(
cm
.
ctx
,
"connCleanup"
)
.
Done
()
for
_
,
c
:=
range
cm
.
getConnsToClose
()
{
log
.
Info
(
"closing conn: "
,
c
.
RemotePeer
())
log
.
Event
(
cm
.
ctx
,
"closeConn"
,
c
.
RemotePeer
())
c
.
Close
()
}
...
...
connmgr_test.go
View file @
bcbce348
...
...
@@ -611,7 +611,6 @@ func TestPeerProtectionMultipleTags(t *testing.T) {
// add 2 more connections, sending the connection manager overboard again.
for
i
:=
0
;
i
<
2
;
i
++
{
rc
:=
randConn
(
t
,
not
.
Disconnected
)
conns
=
append
(
conns
,
rc
)
not
.
Connected
(
nil
,
rc
)
cm
.
TagPeer
(
rc
.
RemotePeer
(),
"test"
,
20
)
}
...
...
@@ -631,7 +630,6 @@ func TestPeerProtectionMultipleTags(t *testing.T) {
// add 2 more connections, sending the connection manager overboard again.
for
i
:=
0
;
i
<
2
;
i
++
{
rc
:=
randConn
(
t
,
not
.
Disconnected
)
conns
=
append
(
conns
,
rc
)
not
.
Connected
(
nil
,
rc
)
cm
.
TagPeer
(
rc
.
RemotePeer
(),
"test"
,
20
)
}
...
...
decay.go
View file @
bcbce348
...
...
@@ -101,8 +101,7 @@ func (d *decayer) RegisterDecayingTag(name string, interval time.Duration, decay
d
.
tagsMu
.
Lock
()
defer
d
.
tagsMu
.
Unlock
()
tag
,
ok
:=
d
.
knownTags
[
name
]
if
ok
{
if
_
,
ok
:=
d
.
knownTags
[
name
];
ok
{
return
nil
,
fmt
.
Errorf
(
"decaying tag with name %s already exists"
,
name
)
}
...
...
@@ -118,7 +117,7 @@ func (d *decayer) RegisterDecayingTag(name string, interval time.Duration, decay
}
lastTick
:=
d
.
lastTick
.
Load
()
.
(
time
.
Time
)
tag
=
&
decayingTag
{
tag
:
=
&
decayingTag
{
trkr
:
d
,
name
:
name
,
interval
:
interval
,
...
...
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