Skip to content

Commit

Permalink
chore: methods renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Jan 24, 2024
1 parent f9fa8f2 commit 2feab3a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions core/services/gateway/handlers/functions/allowlist/allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ func (a *onchainAllowlist) updateFromContractV1(ctx context.Context, blockNum *b
return errors.Wrap(err, "error calling GetAllAllowedSenders")
}
} else {
err = a.syncStoredAllowedAndBlockedSenders(ctx, tosContract, blockNum)
err = a.syncBlockedSenders(ctx, tosContract, blockNum)
if err != nil {
return errors.Wrap(err, "failed to sync the stored allowed and blocked senders")
}

allowedSenderList, err = a.getAllowedSendersInRange(ctx, tosContract, blockNum)
allowedSenderList, err = a.getAllowedSendersBatched(ctx, tosContract, blockNum)
if err != nil {
return errors.Wrap(err, "failed to get allowed senders in rage")
}
Expand All @@ -235,7 +235,7 @@ func (a *onchainAllowlist) updateFromContractV1(ctx context.Context, blockNum *b
return nil
}

func (a *onchainAllowlist) getAllowedSendersInRange(ctx context.Context, tosContract *functions_allow_list.TermsOfServiceAllowList, blockNum *big.Int) ([]common.Address, error) {
func (a *onchainAllowlist) getAllowedSendersBatched(ctx context.Context, tosContract *functions_allow_list.TermsOfServiceAllowList, blockNum *big.Int) ([]common.Address, error) {
allowedSenderList := make([]common.Address, 0)
count, err := tosContract.GetAllowedSendersCount(&bind.CallOpts{
Pending: false,
Expand Down Expand Up @@ -275,9 +275,9 @@ func (a *onchainAllowlist) getAllowedSendersInRange(ctx context.Context, tosCont
return allowedSenderList, nil
}

// syncStoredAllowedAndBlockedSenders fetches the list of blocked addresses from the contract in batches
// syncBlockedSenders fetches the list of blocked addresses from the contract in batches
// and removes the addresses from the functions_allowlist table if present
func (a *onchainAllowlist) syncStoredAllowedAndBlockedSenders(ctx context.Context, tosContract *functions_allow_list.TermsOfServiceAllowList, blockNum *big.Int) error {
func (a *onchainAllowlist) syncBlockedSenders(ctx context.Context, tosContract *functions_allow_list.TermsOfServiceAllowList, blockNum *big.Int) error {
count, err := tosContract.GetBlockedSendersCount(&bind.CallOpts{
Pending: false,
BlockNumber: blockNum,
Expand Down Expand Up @@ -336,7 +336,7 @@ func (a *onchainAllowlist) loadStoredAllowedSenderList() {

allowedList = append(allowedList, asBatch...)

if len(asBatch) != int(a.config.StoredAllowlistBatchSize) {
if len(asBatch) < int(a.config.StoredAllowlistBatchSize) {
break
}
offset += a.config.StoredAllowlistBatchSize
Expand Down
30 changes: 15 additions & 15 deletions core/services/gateway/handlers/functions/handler.functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/gateway/config"
"github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers"
hc "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/common"
all "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/functions/allowlist"
sub "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/functions/subscriptions"
fallow "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/functions/allowlist"
fsub "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/functions/subscriptions"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
)

Expand Down Expand Up @@ -62,10 +62,10 @@ var (
type FunctionsHandlerConfig struct {
ChainID string `json:"chainId"`
// Not specifying OnchainAllowlist config disables allowlist checks
OnchainAllowlist *all.OnchainAllowlistConfig `json:"onchainAllowlist"`
OnchainAllowlist *fallow.OnchainAllowlistConfig `json:"onchainAllowlist"`
// Not specifying OnchainSubscriptions config disables minimum balance checks
OnchainSubscriptions *sub.OnchainSubscriptionsConfig `json:"onchainSubscriptions"`
MinimumSubscriptionBalance *assets.Link `json:"minimumSubscriptionBalance"`
OnchainSubscriptions *fsub.OnchainSubscriptionsConfig `json:"onchainSubscriptions"`
MinimumSubscriptionBalance *assets.Link `json:"minimumSubscriptionBalance"`
// Not specifying RateLimiter config disables rate limiting
UserRateLimiter *hc.RateLimiterConfig `json:"userRateLimiter"`
NodeRateLimiter *hc.RateLimiterConfig `json:"nodeRateLimiter"`
Expand All @@ -81,8 +81,8 @@ type functionsHandler struct {
donConfig *config.DONConfig
don handlers.DON
pendingRequests hc.RequestCache[PendingRequest]
allowlist all.OnchainAllowlist
subscriptions sub.OnchainSubscriptions
allowlist fallow.OnchainAllowlist
subscriptions fsub.OnchainSubscriptions
minimumBalance *assets.Link
userRateLimiter *hc.RateLimiter
nodeRateLimiter *hc.RateLimiter
Expand All @@ -107,18 +107,18 @@ func NewFunctionsHandlerFromConfig(handlerConfig json.RawMessage, donConfig *con
return nil, err
}
lggr = lggr.Named("FunctionsHandler:" + donConfig.DonId)
var allowlist all.OnchainAllowlist
var allowlist fallow.OnchainAllowlist
if cfg.OnchainAllowlist != nil {
chain, err2 := legacyChains.Get(cfg.ChainID)
if err2 != nil {
return nil, err2
}

orm, err2 := all.NewORM(db, lggr, qcfg, cfg.OnchainAllowlist.ContractAddress)
orm, err2 := fallow.NewORM(db, lggr, qcfg, cfg.OnchainAllowlist.ContractAddress)
if err2 != nil {
return nil, err2
}
allowlist, err2 = all.NewOnchainAllowlist(chain.Client(), *cfg.OnchainAllowlist, orm, lggr)
allowlist, err2 = fallow.NewOnchainAllowlist(chain.Client(), *cfg.OnchainAllowlist, orm, lggr)
if err2 != nil {
return nil, err2
}
Expand All @@ -136,19 +136,19 @@ func NewFunctionsHandlerFromConfig(handlerConfig json.RawMessage, donConfig *con
return nil, err
}
}
var subscriptions sub.OnchainSubscriptions
var subscriptions fsub.OnchainSubscriptions
if cfg.OnchainSubscriptions != nil {
chain, err2 := legacyChains.Get(cfg.ChainID)
if err2 != nil {
return nil, err2
}

orm, err2 := sub.NewORM(db, lggr, qcfg, cfg.OnchainSubscriptions.ContractAddress)
orm, err2 := fsub.NewORM(db, lggr, qcfg, cfg.OnchainSubscriptions.ContractAddress)
if err2 != nil {
return nil, err2
}

subscriptions, err2 = sub.NewOnchainSubscriptions(chain.Client(), *cfg.OnchainSubscriptions, orm, lggr)
subscriptions, err2 = fsub.NewOnchainSubscriptions(chain.Client(), *cfg.OnchainSubscriptions, orm, lggr)
if err2 != nil {
return nil, err2
}
Expand All @@ -166,8 +166,8 @@ func NewFunctionsHandler(
donConfig *config.DONConfig,
don handlers.DON,
pendingRequestsCache hc.RequestCache[PendingRequest],
allowlist all.OnchainAllowlist,
subscriptions sub.OnchainSubscriptions,
allowlist fallow.OnchainAllowlist,
subscriptions fsub.OnchainSubscriptions,
minimumBalance *assets.Link,
userRateLimiter *hc.RateLimiter,
nodeRateLimiter *hc.RateLimiter,
Expand Down
4 changes: 2 additions & 2 deletions core/store/migrate/migrations/0221_functions_allowlist.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ CREATE TABLE functions_allowlist(
);

ALTER TABLE functions_subscriptions
ADD CONSTRAINT router_contract_address_octet_lenth CHECK (octet_length(router_contract_address) = 20);
ADD CONSTRAINT router_contract_address_octet_length CHECK (octet_length(router_contract_address) = 20);

-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin

ALTER TABLE functions_subscriptions
DROP CONSTRAINT router_contract_address_octet_lenth;
DROP CONSTRAINT router_contract_address_octet_length;

DROP TABLE IF EXISTS functions_allowlist;
-- +goose StatementEnd

0 comments on commit 2feab3a

Please sign in to comment.