good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b24804d8
Unverified
Commit
b24804d8
authored
Mar 3, 2021
by
Zsolt Felföldi
Committed by
GitHub
Mar 3, 2021
Browse files
Options
Downloads
Patches
Plain Diff
les: fix nodiscover option on the client side (#22422)
parent
ba999105
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
les/client.go
+11
-1
11 additions, 1 deletion
les/client.go
les/vflux/client/serverpool.go
+3
-3
3 additions, 3 deletions
les/vflux/client/serverpool.go
les/vflux/client/serverpool_test.go
+1
-1
1 addition, 1 deletion
les/vflux/client/serverpool_test.go
with
15 additions
and
5 deletions
les/client.go
+
11
−
1
View file @
b24804d8
...
...
@@ -115,7 +115,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
p2pConfig
:
&
stack
.
Config
()
.
P2P
,
}
leth
.
serverPool
,
leth
.
serverPoolIterator
=
vfc
.
NewServerPool
(
lesDb
,
[]
byte
(
"serverpool:"
),
time
.
Second
,
leth
.
prenegQuery
,
&
mclock
.
System
{},
config
.
UltraLightServers
,
requestList
)
var
prenegQuery
vfc
.
QueryFunc
if
leth
.
p2pServer
.
DiscV5
!=
nil
{
prenegQuery
=
leth
.
prenegQuery
}
leth
.
serverPool
,
leth
.
serverPoolIterator
=
vfc
.
NewServerPool
(
lesDb
,
[]
byte
(
"serverpool:"
),
time
.
Second
,
prenegQuery
,
&
mclock
.
System
{},
config
.
UltraLightServers
,
requestList
)
leth
.
serverPool
.
AddMetrics
(
suggestedTimeoutGauge
,
totalValueGauge
,
serverSelectableGauge
,
serverConnectedGauge
,
sessionValueMeter
,
serverDialedMeter
)
leth
.
retriever
=
newRetrieveManager
(
peers
,
leth
.
reqDist
,
leth
.
serverPool
.
GetTimeout
)
...
...
@@ -194,6 +198,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
// VfluxRequest sends a batch of requests to the given node through discv5 UDP TalkRequest and returns the responses
func
(
s
*
LightEthereum
)
VfluxRequest
(
n
*
enode
.
Node
,
reqs
vflux
.
Requests
)
vflux
.
Replies
{
if
s
.
p2pServer
.
DiscV5
==
nil
{
return
nil
}
reqsEnc
,
_
:=
rlp
.
EncodeToBytes
(
&
reqs
)
repliesEnc
,
_
:=
s
.
p2pServer
.
DiscV5
.
TalkRequest
(
s
.
serverPool
.
DialNode
(
n
),
"vfx"
,
reqsEnc
)
var
replies
vflux
.
Replies
...
...
@@ -208,6 +215,9 @@ func (s *LightEthereum) VfluxRequest(n *enode.Node, reqs vflux.Requests) vflux.R
func
(
s
*
LightEthereum
)
vfxVersion
(
n
*
enode
.
Node
)
uint
{
if
n
.
Seq
()
==
0
{
var
err
error
if
s
.
p2pServer
.
DiscV5
==
nil
{
return
0
}
if
n
,
err
=
s
.
p2pServer
.
DiscV5
.
RequestENR
(
n
);
n
!=
nil
&&
err
==
nil
&&
n
.
Seq
()
!=
0
{
s
.
serverPool
.
Persist
(
n
)
}
else
{
...
...
This diff is collapsed.
Click to expand it.
les/vflux/client/serverpool.go
+
3
−
3
View file @
b24804d8
...
...
@@ -91,7 +91,7 @@ type nodeHistoryEnc struct {
// queryFunc sends a pre-negotiation query and blocks until a response arrives or timeout occurs.
// It returns 1 if the remote node has confirmed that connection is possible, 0 if not
// possible and -1 if no response arrived (timeout).
type
q
ueryFunc
func
(
*
enode
.
Node
)
int
type
Q
ueryFunc
func
(
*
enode
.
Node
)
int
var
(
clientSetup
=
&
nodestate
.
Setup
{
Version
:
2
}
...
...
@@ -150,7 +150,7 @@ var (
)
// NewServerPool creates a new server pool
func
NewServerPool
(
db
ethdb
.
KeyValueStore
,
dbKey
[]
byte
,
mixTimeout
time
.
Duration
,
query
q
ueryFunc
,
clock
mclock
.
Clock
,
trustedURLs
[]
string
,
requestList
[]
RequestInfo
)
(
*
ServerPool
,
enode
.
Iterator
)
{
func
NewServerPool
(
db
ethdb
.
KeyValueStore
,
dbKey
[]
byte
,
mixTimeout
time
.
Duration
,
query
Q
ueryFunc
,
clock
mclock
.
Clock
,
trustedURLs
[]
string
,
requestList
[]
RequestInfo
)
(
*
ServerPool
,
enode
.
Iterator
)
{
s
:=
&
ServerPool
{
db
:
db
,
clock
:
clock
,
...
...
@@ -246,7 +246,7 @@ func (s *ServerPool) AddSource(source enode.Iterator) {
// addPreNegFilter installs a node filter mechanism that performs a pre-negotiation query.
// Nodes that are filtered out and does not appear on the output iterator are put back
// into redialWait state.
func
(
s
*
ServerPool
)
addPreNegFilter
(
input
enode
.
Iterator
,
query
q
ueryFunc
)
enode
.
Iterator
{
func
(
s
*
ServerPool
)
addPreNegFilter
(
input
enode
.
Iterator
,
query
Q
ueryFunc
)
enode
.
Iterator
{
s
.
fillSet
=
NewFillSet
(
s
.
ns
,
input
,
sfQueried
)
s
.
ns
.
SubscribeState
(
sfQueried
,
func
(
n
*
enode
.
Node
,
oldState
,
newState
nodestate
.
Flags
)
{
if
newState
.
Equals
(
sfQueried
)
{
...
...
This diff is collapsed.
Click to expand it.
les/vflux/client/serverpool_test.go
+
1
−
1
View file @
b24804d8
...
...
@@ -107,7 +107,7 @@ func (s *ServerPoolTest) addTrusted(i int) {
}
func
(
s
*
ServerPoolTest
)
start
()
{
var
testQuery
q
ueryFunc
var
testQuery
Q
ueryFunc
if
s
.
preNeg
{
testQuery
=
func
(
node
*
enode
.
Node
)
int
{
idx
:=
testNodeIndex
(
node
.
ID
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment