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)) }