Skip to content

Commit

Permalink
chore: improve redability
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Jan 4, 2024
1 parent 9a9cf1a commit c52163d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/services/gateway/handlers/functions/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type cachedSubscriptionRow struct {
}

func NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig, routerContractAddress common.Address) (ORM, error) {
if db == nil || cfg == nil || lggr == nil || routerContractAddress == *new(common.Address) {
if db == nil || cfg == nil || lggr == nil || routerContractAddress == (common.Address{}) {
return nil, ErrInvalidParameters
}

Expand Down Expand Up @@ -81,6 +81,8 @@ func (o *orm) GetSubscriptions(offset, limit uint, qopts ...pg.QOpt) ([]CachedSu
return cacheSubscriptions, nil
}

// UpsertSubscription will update if a subscription exists or create if it does not.
// In case a subscription gets deleted we will update it with an owner address equal to 0x0.
func (o *orm) UpsertSubscription(subscription CachedSubscription, qopts ...pg.QOpt) error {
stmt := fmt.Sprintf(`
INSERT INTO %s (subscription_id, owner, balance, blocked_balance, proposed_owner, consumers, flags, router_contract_address)
Expand Down
2 changes: 1 addition & 1 deletion core/services/gateway/handlers/functions/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ func (s *onchainSubscriptions) loadCachedSubscriptions() {
Consumers: cs.Consumers,
Flags: cs.Flags,
})
s.lggr.Debugw("Loading cached subscriptions", "offset", offset, "batch_length", len(csBatch))
}
s.lggr.Debugw("Loading cached subscriptions", "offset", offset, "batch_length", len(csBatch))

if len(csBatch) != int(s.config.CacheBatchSize) {
break
Expand Down

0 comments on commit c52163d

Please sign in to comment.