Skip to content

Commit 049d28e

Browse files
committed
chore: optimize the session usage validate worker
1 parent 249a4e6 commit 049d28e

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

workers/session.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ func NewSessionUsageValidateWorker(c *core.Context, interval time.Duration) cron
195195
handlerFunc := func(ctx context.Context) error {
196196
// Retrieve session records from the database.
197197
query := map[string]interface{}{
198-
"node_addr": c.NodeAddr().String(),
198+
"node_addr": c.NodeAddr().String(),
199+
"service_type": c.Service().Type().String(),
199200
}
200201

201202
items, err := operations.SessionFind(c.Database(), query)
@@ -238,15 +239,6 @@ func NewSessionUsageValidateWorker(c *core.Context, interval time.Duration) cron
238239
removePeer = true
239240
}
240241

241-
// Ensure that only sessions of the current service type are validated.
242-
if item.GetServiceType() != c.Service().Type() {
243-
log.Debug("Skipping peer",
244-
"id", item.GetID(), "peer_id", item.GetPeerID(), "cause", "invalid service type",
245-
"got", item.GetServiceType(), "expected", c.Service().Type(),
246-
)
247-
removePeer = false
248-
}
249-
250242
// If the session exceeded any limits, remove the associated peer.
251243
if removePeer {
252244
log.Debug("Removing peer from service", "id", item.GetID(), "peer_id", item.GetPeerID())

0 commit comments

Comments
 (0)