Skip to content

Commit

Permalink
CNS-213: created templates for filter code
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Jun 6, 2023
1 parent 1be6966 commit 54c066b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions x/pairing/keeper/filters/filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package filters

import (
sdk "github.com/cosmos/cosmos-sdk/types"
epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types"
projectstypes "github.com/lavanet/lava/x/projects/types"
)

type Filter interface {
Filter(ctx sdk.Context, stakeEntry []epochstoragetypes.StakeEntry) []bool
InitFilter(strictestPolicy projectstypes.Policy) bool // return if filter is usable (by the policy)
}

func GetAllFilters() []Filter {
var selectedProvidersFilter SelectedProvidersFilter
var frozenProvidersFilter FrozenProvidersFilter

filters := []Filter{&selectedProvidersFilter, &frozenProvidersFilter}
return filters
}
17 changes: 17 additions & 0 deletions x/pairing/keeper/filters/frozen_providers_filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package filters

import (
sdk "github.com/cosmos/cosmos-sdk/types"
epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types"
projectstypes "github.com/lavanet/lava/x/projects/types"
)

type FrozenProvidersFilter struct{}

func (*FrozenProvidersFilter) Filter(ctx sdk.Context, stakeEntry []epochstoragetypes.StakeEntry) []bool {
return nil
}

func (*FrozenProvidersFilter) InitFilter(strictestPolicy projectstypes.Policy) bool {
return false
}
19 changes: 19 additions & 0 deletions x/pairing/keeper/filters/selected_providers_filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package filters

import (
sdk "github.com/cosmos/cosmos-sdk/types"
epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types"
projectstypes "github.com/lavanet/lava/x/projects/types"
)

type SelectedProvidersFilter struct {
selectedProviders []epochstoragetypes.StakeEntry
}

func (*SelectedProvidersFilter) Filter(ctx sdk.Context, stakeEntry []epochstoragetypes.StakeEntry) []bool {
return nil
}

func (*SelectedProvidersFilter) InitFilter(strictestPolicy projectstypes.Policy) bool {
return false
}

0 comments on commit 54c066b

Please sign in to comment.