Skip to content

Commit b3d0bbf

Browse files
committed
p2p/protocols: simplify reporter.save
1 parent 0ba0936 commit b3d0bbf

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

p2p/protocols/reporter.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ func (r *reporter) run() {
128128

129129
//send the metrics to the DB
130130
func (r *reporter) save() error {
131-
var err error
132131
//create a LevelDB Batch
133132
batch := leveldb.Batch{}
134133
//for each metric in the registry (which is independent)...
@@ -144,13 +143,5 @@ func (r *reporter) save() error {
144143
batch.Put([]byte(name), byteVal)
145144
}
146145
})
147-
if batch.Len() > 0 {
148-
err = r.db.Write(&batch, nil)
149-
if err != nil {
150-
return err
151-
}
152-
batch.Reset()
153-
}
154-
155-
return err
146+
return r.db.Write(&batch, nil)
156147
}

0 commit comments

Comments
 (0)