From b3d0bbf7609a735b07d5250ab8a4690fffac646b Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Mon, 26 Nov 2018 09:41:42 -0500 Subject: [PATCH] p2p/protocols: simplify reporter.save --- p2p/protocols/reporter.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/p2p/protocols/reporter.go b/p2p/protocols/reporter.go index b96e2d0d77..215d4fe31b 100644 --- a/p2p/protocols/reporter.go +++ b/p2p/protocols/reporter.go @@ -128,7 +128,6 @@ func (r *reporter) run() { //send the metrics to the DB func (r *reporter) save() error { - var err error //create a LevelDB Batch batch := leveldb.Batch{} //for each metric in the registry (which is independent)... @@ -144,13 +143,5 @@ func (r *reporter) save() error { batch.Put([]byte(name), byteVal) } }) - if batch.Len() > 0 { - err = r.db.Write(&batch, nil) - if err != nil { - return err - } - batch.Reset() - } - - return err + return r.db.Write(&batch, nil) }