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
210b3eac
Commit
210b3eac
authored
May 27, 2023
by
Felipe Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fixes
parent
3a4c7dd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
consensus_poller.go
proxyd/consensus_poller.go
+5
-7
metrics.go
proxyd/metrics.go
+6
-1
No files found.
proxyd/consensus_poller.go
View file @
210b3eac
...
...
@@ -212,9 +212,6 @@ func NewConsensusPoller(bg *BackendGroup, opts ...ConsensusOpt) *ConsensusPoller
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
state
:=
make
(
map
[
*
Backend
]
*
backendState
,
len
(
bg
.
Backends
))
for
_
,
be
:=
range
bg
.
Backends
{
state
[
be
]
=
&
backendState
{}
}
cp
:=
&
ConsensusPoller
{
cancelFunc
:
cancelFunc
,
...
...
@@ -239,6 +236,7 @@ func NewConsensusPoller(bg *BackendGroup, opts ...ConsensusOpt) *ConsensusPoller
cp
.
asyncHandler
=
NewPollerAsyncHandler
(
ctx
,
cp
)
}
cp
.
Reset
()
cp
.
asyncHandler
.
Init
()
return
cp
...
...
@@ -291,11 +289,11 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) {
log
.
Warn
(
"error updating backend - finalized block"
,
"name"
,
be
.
Name
,
"err"
,
err
)
}
// just for readability
oldFinalized
:=
bs
.
finalizedBlockNumber
oldSafe
:=
bs
.
safeBlockNumber
updateDelay
:=
time
.
Since
(
bs
.
lastUpdate
)
RecordConsensusBackendUpdateDelay
(
be
,
updateDelay
)
RecordConsensusBackendUpdateDelay
(
be
,
bs
.
lastUpdate
)
changed
:=
cp
.
setBackendState
(
be
,
peerCount
,
inSync
,
latestBlockNumber
,
latestBlockHash
,
...
...
@@ -314,7 +312,7 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) {
"latestBlockHash"
,
latestBlockHash
,
"finalizedBlockNumber"
,
finalizedBlockNumber
,
"safeBlockNumber"
,
safeBlockNumber
,
"
updateDelay"
,
updateDelay
)
"
lastUpdate"
,
bs
.
lastUpdate
)
}
// sanity check for latest, safe and finalized block tags
...
...
@@ -658,7 +656,7 @@ func (cp *ConsensusPoller) getConsensusCandidates() map[*Backend]*backendState {
lagging
:=
make
([]
*
Backend
,
0
,
len
(
candidates
))
for
be
,
bs
:=
range
candidates
{
// check if backend is lagging behind the highest block
if
bs
.
latestBlockNumber
<
highestLatestBlock
&&
uint64
(
highestLatestBlock
-
bs
.
latestBlockNumber
)
>
cp
.
maxBlockLag
{
if
uint64
(
highestLatestBlock
-
bs
.
latestBlockNumber
)
>
cp
.
maxBlockLag
{
lagging
=
append
(
lagging
,
be
)
}
}
...
...
proxyd/metrics.go
View file @
210b3eac
...
...
@@ -482,7 +482,12 @@ func RecordConsensusBackendInSync(b *Backend, inSync bool) {
consensusInSyncBackend
.
WithLabelValues
(
b
.
Name
)
.
Set
(
boolToFloat64
(
inSync
))
}
func
RecordConsensusBackendUpdateDelay
(
b
*
Backend
,
delay
time
.
Duration
)
{
func
RecordConsensusBackendUpdateDelay
(
b
*
Backend
,
lastUpdate
time
.
Time
)
{
// avoid recording the delay for the first update
if
lastUpdate
.
IsZero
()
{
return
}
delay
:=
time
.
Since
(
lastUpdate
)
consensusUpdateDelayBackend
.
WithLabelValues
(
b
.
Name
)
.
Set
(
float64
(
delay
.
Milliseconds
()))
}
...
...
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