good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Erigon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
a
Erigon
Commits
55904950
Unverified
Commit
55904950
authored
4 years ago
by
Alex Sharov
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
enr discovery (#1690)
parent
7222cdd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/headers/download/sentry.go
+4
-1
4 additions, 1 deletion
cmd/headers/download/sentry.go
eth/protocols/eth/discovery.go
+10
-3
10 additions, 3 deletions
eth/protocols/eth/discovery.go
eth/protocols/eth/handler.go
+1
-1
1 addition, 1 deletion
eth/protocols/eth/handler.go
with
15 additions
and
5 deletions
cmd/headers/download/sentry.go
+
4
−
1
View file @
55904950
...
...
@@ -646,12 +646,13 @@ func (ss *SentryServerImpl) SendMessageToAll(ctx context.Context, req *proto_sen
}
func
(
ss
*
SentryServerImpl
)
SetStatus
(
_
context
.
Context
,
statusData
*
proto_sentry
.
StatusData
)
(
*
emptypb
.
Empty
,
error
)
{
genesisHash
:=
gointerfaces
.
ConvertH256ToHash
(
statusData
.
ForkData
.
Genesis
)
ss
.
lock
.
Lock
()
defer
ss
.
lock
.
Unlock
()
init
:=
ss
.
statusData
==
nil
if
init
{
var
err
error
genesisHash
:=
gointerfaces
.
ConvertH256ToHash
(
statusData
.
ForkData
.
Genesis
)
ss
.
p2pServer
,
err
=
p2pServer
(
ss
.
ctx
,
ss
,
genesisHash
,
ss
.
natSetting
,
ss
.
port
,
ss
.
staticPeers
,
ss
.
discovery
,
ss
.
netRestrict
)
if
err
!=
nil
{
return
&
empty
.
Empty
{},
err
...
...
@@ -661,6 +662,8 @@ func (ss *SentryServerImpl) SetStatus(_ context.Context, statusData *proto_sentr
return
&
empty
.
Empty
{},
fmt
.
Errorf
(
"could not start server: %w"
,
err
)
}
}
genesisHash
=
gointerfaces
.
ConvertH256ToHash
(
statusData
.
ForkData
.
Genesis
)
ss
.
p2pServer
.
LocalNode
()
.
Set
(
eth
.
CurrentENREntryFromForks
(
statusData
.
ForkData
.
Forks
,
genesisHash
,
statusData
.
MaxBlock
))
ss
.
statusData
=
statusData
return
&
empty
.
Empty
{},
nil
}
...
...
This diff is collapsed.
Click to expand it.
eth/protocols/eth/discovery.go
+
10
−
3
View file @
55904950
...
...
@@ -43,14 +43,21 @@ func (e enrEntry) ENRKey() string {
// head events and updates the requested node record whenever a fork is passed.
func
StartENRUpdater
(
chainConfig
*
params
.
ChainConfig
,
genesisHash
common
.
Hash
,
events
*
remotedbserver
.
Events
,
ln
*
enode
.
LocalNode
)
{
events
.
AddHeaderSubscription
(
func
(
h
*
types
.
Header
)
error
{
ln
.
Set
(
c
urrentENREntry
(
chainConfig
,
genesisHash
,
h
.
Number
.
Uint64
()))
ln
.
Set
(
C
urrentENREntry
(
chainConfig
,
genesisHash
,
h
.
Number
.
Uint64
()))
return
nil
})
}
//
c
urrentENREntry constructs an `eth` ENR entry based on the current state of the chain.
func
c
urrentENREntry
(
chainConfig
*
params
.
ChainConfig
,
genesisHash
common
.
Hash
,
headHeight
uint64
)
*
enrEntry
{
//
C
urrentENREntry constructs an `eth` ENR entry based on the current state of the chain.
func
C
urrentENREntry
(
chainConfig
*
params
.
ChainConfig
,
genesisHash
common
.
Hash
,
headHeight
uint64
)
*
enrEntry
{
return
&
enrEntry
{
ForkID
:
forkid
.
NewID
(
chainConfig
,
genesisHash
,
headHeight
),
}
}
// CurrentENREntryFromForks constructs an `eth` ENR entry based on the current state of the chain.
func
CurrentENREntryFromForks
(
forks
[]
uint64
,
genesisHash
common
.
Hash
,
headHeight
uint64
)
*
enrEntry
{
return
&
enrEntry
{
ForkID
:
forkid
.
NewIDFromForks
(
forks
,
genesisHash
,
headHeight
),
}
}
This diff is collapsed.
Click to expand it.
eth/protocols/eth/handler.go
+
1
−
1
View file @
55904950
...
...
@@ -115,7 +115,7 @@ func MakeProtocols(backend Backend, network uint64, dnsdisc enode.Iterator, chai
PeerInfo
:
func
(
id
enode
.
ID
)
interface
{}
{
return
backend
.
PeerInfo
(
id
)
},
Attributes
:
[]
enr
.
Entry
{
c
urrentENREntry
(
chainConfig
,
genesisHash
,
headHeight
)},
Attributes
:
[]
enr
.
Entry
{
C
urrentENREntry
(
chainConfig
,
genesisHash
,
headHeight
)},
DialCandidates
:
dnsdisc
,
}
}
...
...
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