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
279dc136
Unverified
Commit
279dc136
authored
Jun 19, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Remove unused OnConnect and OnDisconnect hooks
parent
7ce6e3fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
42 deletions
+0
-42
node.go
op-node/p2p/node.go
+0
-8
peer_scorer.go
op-node/p2p/peer_scorer.go
+0
-12
peer_scorer_test.go
op-node/p2p/peer_scorer_test.go
+0
-22
No files found.
op-node/p2p/node.go
View file @
279dc136
...
@@ -118,14 +118,6 @@ func (n *NodeP2P) init(resourcesCtx context.Context, rollupCfg *rollup.Config, l
...
@@ -118,14 +118,6 @@ func (n *NodeP2P) init(resourcesCtx context.Context, rollupCfg *rollup.Config, l
}
}
n
.
store
=
eps
n
.
store
=
eps
n
.
scorer
=
NewScorer
(
rollupCfg
,
eps
,
metrics
,
log
)
n
.
scorer
=
NewScorer
(
rollupCfg
,
eps
,
metrics
,
log
)
n
.
host
.
Network
()
.
Notify
(
&
network
.
NotifyBundle
{
ConnectedF
:
func
(
_
network
.
Network
,
conn
network
.
Conn
)
{
n
.
scorer
.
OnConnect
(
conn
.
RemotePeer
())
},
DisconnectedF
:
func
(
_
network
.
Network
,
conn
network
.
Conn
)
{
n
.
scorer
.
OnDisconnect
(
conn
.
RemotePeer
())
},
})
// notify of any new connections/streams/etc.
// notify of any new connections/streams/etc.
n
.
host
.
Network
()
.
Notify
(
NewNetworkNotifier
(
log
,
metrics
))
n
.
host
.
Network
()
.
Notify
(
NewNetworkNotifier
(
log
,
metrics
))
// note: the IDDelta functionality was removed from libP2P, and no longer needs to be explicitly disabled.
// note: the IDDelta functionality was removed from libP2P, and no longer needs to be explicitly disabled.
...
...
op-node/p2p/peer_scorer.go
View file @
279dc136
...
@@ -35,8 +35,6 @@ type Peerstore interface {
...
@@ -35,8 +35,6 @@ type Peerstore interface {
// Scorer is a peer scorer that scores peers based on application-specific metrics.
// Scorer is a peer scorer that scores peers based on application-specific metrics.
type
Scorer
interface
{
type
Scorer
interface
{
OnConnect
(
id
peer
.
ID
)
OnDisconnect
(
id
peer
.
ID
)
SnapshotHook
()
pubsub
.
ExtendedPeerScoreInspectFn
SnapshotHook
()
pubsub
.
ExtendedPeerScoreInspectFn
}
}
...
@@ -86,13 +84,3 @@ func (s *scorer) SnapshotHook() pubsub.ExtendedPeerScoreInspectFn {
...
@@ -86,13 +84,3 @@ func (s *scorer) SnapshotHook() pubsub.ExtendedPeerScoreInspectFn {
s
.
metricer
.
SetPeerScores
(
allScores
)
s
.
metricer
.
SetPeerScores
(
allScores
)
}
}
}
}
// OnConnect is called when a peer connects.
func
(
s
*
scorer
)
OnConnect
(
id
peer
.
ID
)
{
// TODO(CLI-4003): apply decay to scores, based on last connection time
}
// OnDisconnect is called when a peer disconnects.
func
(
s
*
scorer
)
OnDisconnect
(
id
peer
.
ID
)
{
// TODO(CLI-4003): persist disconnect-time
}
op-node/p2p/peer_scorer_test.go
View file @
279dc136
...
@@ -38,28 +38,6 @@ func TestPeerScorer(t *testing.T) {
...
@@ -38,28 +38,6 @@ func TestPeerScorer(t *testing.T) {
suite
.
Run
(
t
,
new
(
PeerScorerTestSuite
))
suite
.
Run
(
t
,
new
(
PeerScorerTestSuite
))
}
}
// TestScorer_OnConnect ensures we can call the OnConnect method on the peer scorer.
func
(
testSuite
*
PeerScorerTestSuite
)
TestScorer_OnConnect
()
{
scorer
:=
p2p
.
NewScorer
(
&
rollup
.
Config
{
L2ChainID
:
big
.
NewInt
(
123
)},
testSuite
.
mockStore
,
testSuite
.
mockMetricer
,
testSuite
.
logger
,
)
scorer
.
OnConnect
(
peer
.
ID
(
"alice"
))
}
// TestScorer_OnDisconnect ensures we can call the OnDisconnect method on the peer scorer.
func
(
testSuite
*
PeerScorerTestSuite
)
TestScorer_OnDisconnect
()
{
scorer
:=
p2p
.
NewScorer
(
&
rollup
.
Config
{
L2ChainID
:
big
.
NewInt
(
123
)},
testSuite
.
mockStore
,
testSuite
.
mockMetricer
,
testSuite
.
logger
,
)
scorer
.
OnDisconnect
(
peer
.
ID
(
"alice"
))
}
// TestScorer_SnapshotHook tests running the snapshot hook on the peer scorer.
// TestScorer_SnapshotHook tests running the snapshot hook on the peer scorer.
func
(
testSuite
*
PeerScorerTestSuite
)
TestScorer_SnapshotHook
()
{
func
(
testSuite
*
PeerScorerTestSuite
)
TestScorer_SnapshotHook
()
{
scorer
:=
p2p
.
NewScorer
(
scorer
:=
p2p
.
NewScorer
(
...
...
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