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
22054dfb
Commit
22054dfb
authored
Mar 07, 2022
by
Matthew Slipper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indexer: reduce DB load
parent
d5e70866
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
17 deletions
+25
-17
metrics.go
go/indexer/metrics/metrics.go
+1
-1
service.go
go/indexer/services/l1/service.go
+8
-4
service.go
go/indexer/services/l2/service.go
+16
-12
No files found.
go/indexer/metrics/metrics.go
View file @
22054dfb
...
...
@@ -44,7 +44,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
return
&
Metrics
{
SyncHeight
:
promauto
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Name
:
"sync_height"
,
Help
:
"The max height of the indexer's last batch of L1 blocks."
,
Help
:
"The max height of the indexer's last batch of L1
/L1
blocks."
,
Namespace
:
metricsNamespace
,
},
[]
string
{
"chain"
,
...
...
go/indexer/services/l1/service.go
View file @
22054dfb
...
...
@@ -94,9 +94,9 @@ type Service struct {
latestHeader
uint64
headerSelector
*
ConfirmedHeaderSelector
metrics
*
metrics
.
Metrics
metrics
*
metrics
.
Metrics
tokenCache
map
[
common
.
Address
]
*
db
.
Token
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
type
IndexerStatus
struct
{
...
...
@@ -289,10 +289,15 @@ func (s *Service) Update(newHeader *types.Header) error {
logger
.
Error
(
"Error querying state batches"
,
"err"
,
err
)
}
for
_
,
header
:=
range
headers
{
for
i
,
header
:=
range
headers
{
blockHash
:=
header
.
Hash
number
:=
header
.
Number
.
Uint64
()
deposits
:=
depositsByBlockHash
[
blockHash
]
batches
:=
stateBatches
[
blockHash
]
if
len
(
deposits
)
==
0
&&
len
(
batches
)
==
0
&&
i
!=
len
(
headers
)
-
1
{
continue
}
block
:=
&
db
.
IndexedL1Block
{
Hash
:
blockHash
,
...
...
@@ -313,7 +318,6 @@ func (s *Service) Update(newHeader *types.Header) error {
return
err
}
batches
:=
stateBatches
[
blockHash
]
err
=
s
.
cfg
.
DB
.
AddStateBatch
(
batches
)
if
err
!=
nil
{
logger
.
Error
(
...
...
go/indexer/services/l2/service.go
View file @
22054dfb
...
...
@@ -69,15 +69,15 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
}
type
ServiceConfig
struct
{
Context
context
.
Context
Metrics
*
metrics
.
Metrics
L2Client
*
l2ethclient
.
Client
ChainID
*
big
.
Int
ConfDepth
uint64
MaxHeaderBatchSize
uint64
StartBlockNumber
uint64
StartBlockHash
string
DB
*
db
.
Database
Context
context
.
Context
Metrics
*
metrics
.
Metrics
L2Client
*
l2ethclient
.
Client
ChainID
*
big
.
Int
ConfDepth
uint64
MaxHeaderBatchSize
uint64
StartBlockNumber
uint64
StartBlockHash
string
DB
*
db
.
Database
}
type
Service
struct
{
...
...
@@ -89,9 +89,9 @@ type Service struct {
latestHeader
uint64
headerSelector
*
ConfirmedHeaderSelector
metrics
*
metrics
.
Metrics
metrics
*
metrics
.
Metrics
tokenCache
map
[
common
.
Address
]
*
db
.
Token
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
type
IndexerStatus
struct
{
...
...
@@ -267,11 +267,15 @@ func (s *Service) Update(newHeader *types.Header) error {
}
}
for
_
,
header
:=
range
headers
{
for
i
,
header
:=
range
headers
{
blockHash
:=
header
.
Hash
()
number
:=
header
.
Number
.
Uint64
()
withdrawals
:=
withdrawalsByBlockHash
[
blockHash
]
if
len
(
withdrawals
)
==
0
&&
i
!=
len
(
headers
)
-
1
{
continue
}
block
:=
&
db
.
IndexedL2Block
{
Hash
:
blockHash
,
ParentHash
:
header
.
ParentHash
,
...
...
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