From 06201c3231594d746bbcee2ccf4616ab2a798583 Mon Sep 17 00:00:00 2001 From: Rafael Sampaio <5679073+r4f4ss@users.noreply.github.com> Date: Tue, 29 Oct 2024 01:36:08 -0300 Subject: [PATCH] fix error verification --- portalnetwork/beacon/storage.go | 4 ++-- portalnetwork/history/storage.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/portalnetwork/beacon/storage.go b/portalnetwork/beacon/storage.go index ff90835313d8..b83eb28cc0dc 100644 --- a/portalnetwork/beacon/storage.go +++ b/portalnetwork/beacon/storage.go @@ -185,7 +185,7 @@ func (bs *BeaconStorage) getLcUpdateValueByRange(start, end uint64) ([]byte, err func (bs *BeaconStorage) putContentValue(contentId, contentKey, value []byte) error { length := 32 + len(contentKey) + len(value) _, err := bs.db.ExecContext(context.Background(), InsertQueryBeacon, contentId, contentKey, value, length) - if metrics.Enabled && err != nil { + if metrics.Enabled && err == nil { portalStorageMetrics.EntriesCount.Inc(1) portalStorageMetrics.ContentStorageUsage.Inc(int64(len(value))) } @@ -194,7 +194,7 @@ func (bs *BeaconStorage) putContentValue(contentId, contentKey, value []byte) er func (bs *BeaconStorage) putLcUpdate(period uint64, value []byte) error { _, err := bs.db.ExecContext(context.Background(), InsertLCUpdateQuery, period, value, 0, len(value)) - if metrics.Enabled && err != nil { + if metrics.Enabled && err == nil { portalStorageMetrics.EntriesCount.Inc(1) portalStorageMetrics.ContentStorageUsage.Inc(int64(len(value))) } diff --git a/portalnetwork/history/storage.go b/portalnetwork/history/storage.go index ee43fb246eb5..57b8f49fd877 100644 --- a/portalnetwork/history/storage.go +++ b/portalnetwork/history/storage.go @@ -456,7 +456,7 @@ func (p *ContentStorage) del(contentId []byte) error { } } _, err = p.delStmt.Exec(contentId) - if metrics.Enabled && err != nil { + if metrics.Enabled && err == nil { portalStorageMetrics.EntriesCount.Dec(1) portalStorageMetrics.ContentStorageUsage.Dec(int64(sizeDel)) } @@ -480,7 +480,7 @@ func (p *ContentStorage) batchDel(ids [][]byte) error { // delete items _, err = p.sqliteDB.Exec(query, args...) - if metrics.Enabled && err != nil { + if metrics.Enabled && err == nil { portalStorageMetrics.EntriesCount.Dec(int64(len(args))) portalStorageMetrics.ContentStorageUsage.Dec(int64(sizeDel)) } @@ -509,7 +509,7 @@ func (p *ContentStorage) deleteContentOutOfRadius(radius *uint256.Int) error { } count, err := res.RowsAffected() p.log.Trace("delete items", "count", count) - if metrics.Enabled && err != nil { + if metrics.Enabled && err == nil { portalStorageMetrics.EntriesCount.Dec(count) portalStorageMetrics.ContentStorageUsage.Dec(int64(sizeDel)) }