Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2e7bed79
Unverified
Commit
2e7bed79
authored
May 26, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Enable ban expiry gater.
Ensures that banned peers are unable to connect until the ban expires.
parent
bd55b36f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
8 deletions
+17
-8
host.go
op-node/p2p/host.go
+1
-3
node.go
op-node/p2p/node.go
+1
-5
iface.go
op-node/p2p/store/iface.go
+3
-0
scorebook.go
op-node/p2p/store/scorebook.go
+8
-0
scorebook_test.go
op-node/p2p/store/scorebook_test.go
+4
-0
No files found.
op-node/p2p/host.go
View file @
2e7bed79
...
...
@@ -163,9 +163,7 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter, metrics Host
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to open connection gater: %w"
,
err
)
}
// TODO(CLI-4015): apply connGtr enhancements
// connGtr = gating.AddBanExpiry(connGtr, ps, log, cl, reporter)
//connGtr = gating.AddScoring(connGtr, ps, 0)
connGtr
=
gating
.
AddBanExpiry
(
connGtr
,
ps
,
log
,
clock
.
SystemClock
,
metrics
)
connGtr
=
gating
.
AddMetering
(
connGtr
,
metrics
)
connMngr
,
err
:=
DefaultConnManager
(
conf
)
...
...
op-node/p2p/node.go
View file @
2e7bed79
...
...
@@ -206,11 +206,7 @@ func (n *NodeP2P) Peers() []peer.ID {
}
func
(
n
*
NodeP2P
)
GetPeerScore
(
id
peer
.
ID
)
(
float64
,
error
)
{
scores
,
err
:=
n
.
store
.
GetPeerScores
(
id
)
if
err
!=
nil
{
return
0
,
err
}
return
scores
.
Gossip
.
Total
,
nil
return
n
.
store
.
GetPeerScore
(
id
)
}
func
(
n
*
NodeP2P
)
IsStatic
(
id
peer
.
ID
)
bool
{
...
...
op-node/p2p/store/iface.go
View file @
2e7bed79
...
...
@@ -37,6 +37,9 @@ type ScoreDatastore interface {
// GetPeerScores returns the current scores for the specified peer
GetPeerScores
(
id
peer
.
ID
)
(
PeerScores
,
error
)
// GetPeerScore returns the current combined score for the specified peer
GetPeerScore
(
id
peer
.
ID
)
(
float64
,
error
)
// SetScore applies the given store diff to the specified peer
SetScore
(
id
peer
.
ID
,
diff
ScoreDiff
)
error
}
...
...
op-node/p2p/store/scorebook.go
View file @
2e7bed79
...
...
@@ -78,6 +78,14 @@ func (d *scoreBook) GetPeerScores(id peer.ID) (PeerScores, error) {
return
record
.
PeerScores
,
nil
}
func
(
d
*
scoreBook
)
GetPeerScore
(
id
peer
.
ID
)
(
float64
,
error
)
{
scores
,
err
:=
d
.
GetPeerScores
(
id
)
if
err
!=
nil
{
return
0
,
err
}
return
scores
.
Gossip
.
Total
,
nil
}
func
(
d
*
scoreBook
)
SetScore
(
id
peer
.
ID
,
diff
ScoreDiff
)
error
{
return
d
.
book
.
SetRecord
(
id
,
diff
)
}
...
...
op-node/p2p/store/scorebook_test.go
View file @
2e7bed79
...
...
@@ -188,6 +188,10 @@ func assertPeerScores(t *testing.T, store ExtendedPeerstore, id peer.ID, expecte
result
,
err
:=
store
.
GetPeerScores
(
id
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
result
,
expected
)
score
,
err
:=
store
.
GetPeerScore
(
id
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
expected
.
Gossip
.
Total
,
score
)
}
func
createMemoryStore
(
t
*
testing
.
T
)
ExtendedPeerstore
{
...
...
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