mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
eth/protocols/snap: add logs
This commit is contained in:
parent
0a965ba99f
commit
93481b2843
1 changed files with 16 additions and 7 deletions
|
|
@ -502,8 +502,11 @@ type Syncer struct {
|
|||
storageHealed uint64 // Number of storage slots downloaded during the healing stage
|
||||
storageHealedBytes common.StorageSize // Number of raw storage bytes persisted to disk during the healing stage
|
||||
|
||||
startTime time.Time // Time instance when snapshot sync started
|
||||
logTime time.Time // Time instance when status was last reported
|
||||
startTime time.Time // Time instance when snapshot sync started
|
||||
healStartTime time.Time // Time instance when the state healing started
|
||||
syncTimeOnce sync.Once // Ensure that the state sync time is uploaded only once
|
||||
healTimeOnce sync.Once // Ensure that the state healing time is uploaded only once
|
||||
logTime time.Time // Time instance when status was last reported
|
||||
|
||||
pend sync.WaitGroup // Tracks network request goroutines for graceful shutdown
|
||||
lock sync.RWMutex // Protects fields that can change outside of sync (peers, reqs, root)
|
||||
|
|
@ -679,15 +682,16 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
|
|||
bytecodeHealReqFails = make(chan *bytecodeHealRequest)
|
||||
trienodeHealResps = make(chan *trienodeHealResponse)
|
||||
bytecodeHealResps = make(chan *bytecodeHealResponse)
|
||||
syncTime = time.Now()
|
||||
)
|
||||
for {
|
||||
// Remove all completed tasks and terminate sync if everything's done
|
||||
s.cleanStorageTasks()
|
||||
s.cleanAccountTasks()
|
||||
if len(s.tasks) == 0 && s.healer.scheduler.Pending() == 0 {
|
||||
// healing done
|
||||
healTimeGauge.Update(int64(time.Since(syncTime)))
|
||||
s.healTimeOnce.Do(func() {
|
||||
healTimeGauge.Update(int64(time.Since(s.healStartTime)))
|
||||
log.Info("State healing phase is completed", "elapsed", common.PrettyDuration(time.Since(s.healStartTime)))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
// Assign all the data retrieval tasks to any free peers
|
||||
|
|
@ -697,8 +701,13 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
|
|||
|
||||
if len(s.tasks) == 0 {
|
||||
// Sync phase done, push elapsed time to metrics
|
||||
syncTimeGauge.Update(int64(time.Since(s.startTime)))
|
||||
syncTime = time.Now()
|
||||
s.syncTimeOnce.Do(func() {
|
||||
syncTimeGauge.Update(int64(time.Since(s.startTime)))
|
||||
log.Info("State sync phase is completed", "elapsed", common.PrettyDuration(time.Since(s.startTime)))
|
||||
})
|
||||
if s.healStartTime.IsZero() {
|
||||
s.healStartTime = time.Now()
|
||||
}
|
||||
// run heal phase
|
||||
s.assignTrienodeHealTasks(trienodeHealResps, trienodeHealReqFails, cancel)
|
||||
s.assignBytecodeHealTasks(bytecodeHealResps, bytecodeHealReqFails, cancel)
|
||||
|
|
|
|||
Loading…
Reference in a new issue