mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
no need chan if init done
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
b1e0361d32
commit
f0c815e4c9
1 changed files with 7 additions and 7 deletions
|
|
@ -141,16 +141,15 @@ func (g *StateSizeGenerator) generate() {
|
||||||
|
|
||||||
// initialize starts the initialization process if not already initialized
|
// initialize starts the initialization process if not already initialized
|
||||||
func (g *StateSizeGenerator) initialize() chan struct{} {
|
func (g *StateSizeGenerator) initialize() chan struct{} {
|
||||||
initDone := make(chan struct{})
|
|
||||||
|
|
||||||
// Check if we already have existing metrics
|
// Check if we already have existing metrics
|
||||||
if g.hasExistingMetrics() {
|
if g.hasExistingMetrics() {
|
||||||
log.Info("State size metrics already initialized")
|
log.Info("State size metrics already initialized")
|
||||||
g.initialized.Store(true)
|
g.initialized.Store(true)
|
||||||
close(initDone)
|
return nil
|
||||||
return initDone
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initDone := make(chan struct{})
|
||||||
|
|
||||||
// Wait for snapshot completion and then initialize
|
// Wait for snapshot completion and then initialize
|
||||||
go func() {
|
go func() {
|
||||||
defer close(initDone)
|
defer close(initDone)
|
||||||
|
|
@ -166,6 +165,7 @@ func (g *StateSizeGenerator) initialize() chan struct{} {
|
||||||
root, done := g.triedb.SnapshotCompleted()
|
root, done := g.triedb.SnapshotCompleted()
|
||||||
if done {
|
if done {
|
||||||
g.metrics.Root = root
|
g.metrics.Root = root
|
||||||
|
g.buffered.Root = root
|
||||||
break LOOP
|
break LOOP
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
|
@ -190,8 +190,9 @@ func (g *StateSizeGenerator) initialize() chan struct{} {
|
||||||
|
|
||||||
// mergeBufferedMetrics merges buffered metrics into main metrics
|
// mergeBufferedMetrics merges buffered metrics into main metrics
|
||||||
func (g *StateSizeGenerator) mergeBufferedMetrics() {
|
func (g *StateSizeGenerator) mergeBufferedMetrics() {
|
||||||
if g.buffered != nil && g.buffered.Root != (common.Hash{}) {
|
if g.buffered != nil {
|
||||||
log.Info("Merging buffered metrics into main metrics")
|
log.Info("Merging buffered metrics into main metrics")
|
||||||
|
g.metrics.Root = g.buffered.Root
|
||||||
g.metrics.AccountCount += g.buffered.AccountCount
|
g.metrics.AccountCount += g.buffered.AccountCount
|
||||||
g.metrics.AccountBytes += g.buffered.AccountBytes
|
g.metrics.AccountBytes += g.buffered.AccountBytes
|
||||||
g.metrics.StorageCount += g.buffered.StorageCount
|
g.metrics.StorageCount += g.buffered.StorageCount
|
||||||
|
|
@ -201,8 +202,7 @@ func (g *StateSizeGenerator) mergeBufferedMetrics() {
|
||||||
g.metrics.ContractCount += g.buffered.ContractCount
|
g.metrics.ContractCount += g.buffered.ContractCount
|
||||||
g.metrics.ContractBytes += g.buffered.ContractBytes
|
g.metrics.ContractBytes += g.buffered.ContractBytes
|
||||||
|
|
||||||
// Reset buffered metrics
|
g.buffered = nil
|
||||||
g.buffered = &StateSizeMetrics{Root: g.metrics.Root}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue