mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
use atomic.Uint64
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
45dd6c5e2c
commit
fb2c4c3c52
1 changed files with 7 additions and 7 deletions
|
|
@ -433,8 +433,8 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
|||
unaccounted stat
|
||||
|
||||
// Totals
|
||||
totalSize uint64
|
||||
totalCount int64
|
||||
totalSize atomic.Uint64
|
||||
totalCount atomic.Int64
|
||||
|
||||
unaccountedKeys = make(map[[2]byte][]byte)
|
||||
unaccountedMu sync.Mutex
|
||||
|
|
@ -450,8 +450,8 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
|||
key = it.Key()
|
||||
size = common.StorageSize(len(key) + len(it.Value()))
|
||||
)
|
||||
atomic.AddUint64(&totalSize, uint64(size))
|
||||
atomic.AddInt64(&totalCount, 1)
|
||||
totalSize.Add(uint64(size))
|
||||
totalCount.Add(1)
|
||||
|
||||
switch {
|
||||
case bytes.HasPrefix(key, headerPrefix) && len(key) == (len(headerPrefix)+8+common.HashLength):
|
||||
|
|
@ -604,16 +604,16 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
|||
fmt.Sprintf("%d", ancient.count()),
|
||||
})
|
||||
}
|
||||
atomic.AddUint64(&totalSize, uint64(ancient.size()))
|
||||
totalSize.Add(uint64(ancient.size()))
|
||||
}
|
||||
|
||||
table := newTableWriter(os.Stdout)
|
||||
table.SetHeader([]string{"Database", "Category", "Size", "Items"})
|
||||
table.SetFooter([]string{"", "Total", common.StorageSize(atomic.LoadUint64(&totalSize)).String(), fmt.Sprintf("%d", atomic.LoadInt64(&totalCount))})
|
||||
table.SetFooter([]string{"", "Total", common.StorageSize(totalSize.Load()).String(), fmt.Sprintf("%d", totalCount.Load())})
|
||||
table.AppendBulk(stats)
|
||||
table.Render()
|
||||
|
||||
log.Info("Parallel database inspection completed", "total_entries", atomic.LoadInt64(&totalCount), "elapsed", common.PrettyDuration(time.Since(start)))
|
||||
log.Info("Parallel database inspection completed", "total_entries", totalCount.Load(), "elapsed", common.PrettyDuration(time.Since(start)))
|
||||
|
||||
if unaccounted.GetSize() > 0 {
|
||||
log.Error("Database contains unaccounted data", "size", unaccounted.GetSize(), "count", unaccounted.GetCount())
|
||||
|
|
|
|||
Loading…
Reference in a new issue