mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
whisper: statistics updated
This commit is contained in:
parent
3b7288006c
commit
9f3c9b40b9
1 changed files with 5 additions and 6 deletions
|
|
@ -647,14 +647,13 @@ func (w *Whisper) expire() {
|
||||||
now := uint32(time.Now().Unix())
|
now := uint32(time.Now().Unix())
|
||||||
for expiry, hashSet := range w.expirations {
|
for expiry, hashSet := range w.expirations {
|
||||||
if expiry < now {
|
if expiry < now {
|
||||||
w.stats.messagesCleared++
|
|
||||||
|
|
||||||
// Dump all expired messages and remove timestamp
|
// Dump all expired messages and remove timestamp
|
||||||
hashSet.Each(func(v interface{}) bool {
|
hashSet.Each(func(v interface{}) bool {
|
||||||
sz := w.envelopes[v.(common.Hash)].size()
|
sz := w.envelopes[v.(common.Hash)].size()
|
||||||
|
delete(w.envelopes, v.(common.Hash))
|
||||||
|
w.stats.messagesCleared++
|
||||||
w.stats.memoryCleared += sz
|
w.stats.memoryCleared += sz
|
||||||
w.stats.memoryUsed -= sz
|
w.stats.memoryUsed -= sz
|
||||||
delete(w.envelopes, v.(common.Hash))
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
w.expirations[expiry].Clear()
|
w.expirations[expiry].Clear()
|
||||||
|
|
@ -664,10 +663,10 @@ func (w *Whisper) expire() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Whisper) Stats() string {
|
func (w *Whisper) Stats() string {
|
||||||
result := fmt.Sprintf("Memory usage: %d bytes.\nAverage messages cleared per expiry cycle: %d.",
|
result := fmt.Sprintf("Memory usage: %d bytes. Average messages cleared per expiry cycle: %d. Total messages cleared: %d.",
|
||||||
w.stats.memoryUsed, w.stats.totalMessagesCleared/w.stats.cycles)
|
w.stats.memoryUsed, w.stats.totalMessagesCleared/w.stats.cycles, w.stats.totalMessagesCleared)
|
||||||
if w.stats.messagesCleared > 0 {
|
if w.stats.messagesCleared > 0 {
|
||||||
result += fmt.Sprintf("\nLatest expiry cycle cleared %d messages (%d bytes).",
|
result += fmt.Sprintf(" Latest expiry cycle cleared %d messages (%d bytes).",
|
||||||
w.stats.messagesCleared, w.stats.memoryCleared)
|
w.stats.messagesCleared, w.stats.memoryCleared)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue