Skip to content

Commit

Permalink
fix staticcheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Nov 29, 2023
1 parent e5f5716 commit c5c0119
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 29 deletions.
4 changes: 2 additions & 2 deletions cache/tiered_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type cachedValue struct {
Value interface{} `json:"v"`
}

var CacheMissError error = errors.New("cache miss")
var ErrCacheMiss error = errors.New("cache miss")

type RemoteCache interface {
Set(ctx context.Context, key string, value any, expiration time.Duration) error
Expand Down Expand Up @@ -100,7 +100,7 @@ func (cache *TieredCache) Get(key string, returnValue interface{}) (interface{},
}

if cache.remoteCache == nil {
return nil, CacheMissError
return nil, ErrCacheMiss
}

// retrieve the key from the remote cache
Expand Down
2 changes: 1 addition & 1 deletion handlers/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func getClientsPageData() (*models.ClientsPageData, error) {
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.ClientsPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func getEpochPageData(epoch uint64) (*models.EpochPageData, error) {
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.EpochPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/epochs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func getEpochsPageData(firstEpoch uint64, pageSize uint64) (*models.EpochsPageDa
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.EpochsPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/sirupsen/logrus"
)

var InvalidPageModelError = errors.New("invalid page model")
var ErrInvalidPageModel = errors.New("invalid page model")

type customFileServer struct {
handler http.Handler
Expand Down
2 changes: 1 addition & 1 deletion handlers/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func getForksPageData() (*models.ForksPageData, error) {
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.ForksPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func getIndexPageData() (*models.IndexPageData, error) {
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.IndexPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func getSlotPageData(blockSlot int64, blockRoot []byte, loadDuties bool) (*model
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.SlotPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func getSlotsPageData(firstSlot uint64, pageSize uint64) (*models.SlotsPageData,
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.SlotsPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/slots_filtered.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func getFilteredSlotsPageData(pageIdx uint64, pageSize uint64, graffiti string,
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.SlotsFilteredPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func getValidatorPageData(validatorIndex uint64) (*models.ValidatorPageData, err
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.ValidatorPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/validator_slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func getValidatorSlotsPageData(validator uint64, pageIdx uint64, pageSize uint64
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.ValidatorSlotsPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getValidatorsPageData(firstValIdx uint64, pageSize uint64, sortOrder string
if pageErr == nil && pageRes != nil {
resData, resOk := pageRes.(*models.ValidatorsPageData)
if !resOk {
return nil, InvalidPageModelError
return nil, ErrInvalidPageModel
}
pageData = resData
}
Expand Down
10 changes: 3 additions & 7 deletions indexer/cache_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,12 @@ func (cache *indexerCache) processCachePersistence() error {
var minPruneSlot int64 = -1
if headEpoch >= uint64(cache.indexer.cachePersistenceDelay) {
persistEpoch := headEpoch - uint64(cache.indexer.cachePersistenceDelay)
if persistEpoch >= 0 {
minPersistSlot = int64((persistEpoch+1)*utils.Config.Chain.Config.SlotsPerEpoch) - 1
minPersistEpoch = int64(persistEpoch)
}
minPersistSlot = int64((persistEpoch+1)*utils.Config.Chain.Config.SlotsPerEpoch) - 1
minPersistEpoch = int64(persistEpoch)
}
if headEpoch >= uint64(cache.indexer.inMemoryEpochs) {
pruneEpoch := headEpoch - uint64(cache.indexer.inMemoryEpochs)
if pruneEpoch >= 0 {
minPruneSlot = int64((pruneEpoch+1)*utils.Config.Chain.Config.SlotsPerEpoch) - 1
}
minPruneSlot = int64((pruneEpoch+1)*utils.Config.Chain.Config.SlotsPerEpoch) - 1
}
for slot, blocks := range cache.slotMap {
if int64(slot) <= minPersistSlot {
Expand Down
6 changes: 2 additions & 4 deletions services/beaconservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,8 @@ func (bs *BeaconService) GetProposerAssignments(firstEpoch uint64, lastEpoch uin
if epochStats != nil {
synchronizedEpochs[epoch] = true
proposers := epochStats.TryGetProposerAssignments()
if proposers != nil {
for slot, vidx := range proposers {
proposerAssignments[slot] = vidx
}
for slot, vidx := range proposers {
proposerAssignments[slot] = vidx
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions services/fnsignatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
)

type TxSignaturesService struct {
mutex sync.Mutex
}

var GlobalTxSignaturesService *TxSignaturesService
Expand Down Expand Up @@ -130,16 +129,13 @@ func (tss *TxSignaturesService) LookupSignatures(sigBytes []types.TxSignatureByt
}

nonfoundLookups := make([]*TxSignaturesLookup, 0)
nonfoundLookupBytes := make([]types.TxSignatureBytes, 0)
for _, l := range unresolvedLookups {
if l == nil {
break
}
nonfoundLookups = append(nonfoundLookups, l)
nonfoundLookupBytes = append(nonfoundLookupBytes, l.Bytes)
}
unresolvedLookups = nonfoundLookups
unresolvedLookupBytes = nonfoundLookupBytes
}

// add pending signature lookups
Expand Down

0 comments on commit c5c0119

Please sign in to comment.