p2p/protocols: fix possible metric loss in AccountingMetrics

This commit is contained in:
Janos Guljas 2019-01-28 16:41:46 +01:00
parent 616cf78203
commit b0b3b0fcb3

View file

@ -36,6 +36,10 @@ type AccountingMetrics struct {
//for a graceful cleanup
func (am *AccountingMetrics) Close() {
close(am.reporter.quit)
// save account metrics on close to avoid data loss
// when more metrics are measured between the last
// reporter run ticker tick and the close
am.reporter.save()
am.reporter.db.Close()
}