mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Enable wastedassign linter & fix findings (#13507)
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
parent
c4c28e4825
commit
835dce5f6e
@ -80,7 +80,6 @@ linters:
|
|||||||
- thelper
|
- thelper
|
||||||
- unparam
|
- unparam
|
||||||
- varnamelen
|
- varnamelen
|
||||||
- wastedassign
|
|
||||||
- wrapcheck
|
- wrapcheck
|
||||||
- wsl
|
- wsl
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func (s *Service) BlockByTimestamp(ctx context.Context, time uint64) (*types.Hea
|
|||||||
cursorNum := big.NewInt(0).SetUint64(latestBlkHeight)
|
cursorNum := big.NewInt(0).SetUint64(latestBlkHeight)
|
||||||
cursorTime := latestBlkTime
|
cursorTime := latestBlkTime
|
||||||
|
|
||||||
numOfBlocks := uint64(0)
|
var numOfBlocks uint64
|
||||||
estimatedBlk := cursorNum.Uint64()
|
estimatedBlk := cursorNum.Uint64()
|
||||||
maxTimeBuffer := searchThreshold * params.BeaconConfig().SecondsPerETH1Block
|
maxTimeBuffer := searchThreshold * params.BeaconConfig().SecondsPerETH1Block
|
||||||
// Terminate if we can't find an acceptable block after
|
// Terminate if we can't find an acceptable block after
|
||||||
|
@ -60,7 +60,7 @@ func NewFieldTrie(field types.FieldIndex, fieldInfo types.DataType, elements int
|
|||||||
if err := validateElements(field, fieldInfo, elements, length); err != nil {
|
if err := validateElements(field, fieldInfo, elements, length); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
numOfElems := 0
|
var numOfElems int
|
||||||
if val, ok := elements.(sliceAccessor); ok {
|
if val, ok := elements.(sliceAccessor); ok {
|
||||||
numOfElems = val.Len(val.State())
|
numOfElems = val.Len(val.State())
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +210,7 @@ func (s *Service) statusRPCHandler(ctx context.Context, msg interface{}, stream
|
|||||||
"error": err,
|
"error": err,
|
||||||
}).Debug("Invalid status message from peer")
|
}).Debug("Invalid status message from peer")
|
||||||
|
|
||||||
respCode := byte(0)
|
var respCode byte
|
||||||
switch err {
|
switch err {
|
||||||
case p2ptypes.ErrGeneric:
|
case p2ptypes.ErrGeneric:
|
||||||
respCode = responseCodeServerError
|
respCode = responseCodeServerError
|
||||||
|
@ -257,7 +257,8 @@ func (s *Service) subscribeWithBase(topic string, validator wrappedVal, handle s
|
|||||||
func (s *Service) wrapAndReportValidation(topic string, v wrappedVal) (string, pubsub.ValidatorEx) {
|
func (s *Service) wrapAndReportValidation(topic string, v wrappedVal) (string, pubsub.ValidatorEx) {
|
||||||
return topic, func(ctx context.Context, pid peer.ID, msg *pubsub.Message) (res pubsub.ValidationResult) {
|
return topic, func(ctx context.Context, pid peer.ID, msg *pubsub.Message) (res pubsub.ValidationResult) {
|
||||||
defer messagehandler.HandlePanic(ctx, msg)
|
defer messagehandler.HandlePanic(ctx, msg)
|
||||||
res = pubsub.ValidationIgnore // Default: ignore any message that panics.
|
// Default: ignore any message that panics.
|
||||||
|
res = pubsub.ValidationIgnore // nolint:wastedassign
|
||||||
ctx, cancel := context.WithTimeout(ctx, pubsubMessageTimeout)
|
ctx, cancel := context.WithTimeout(ctx, pubsubMessageTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
messageReceivedCounter.WithLabelValues(topic).Inc()
|
messageReceivedCounter.WithLabelValues(topic).Inc()
|
||||||
@ -781,10 +782,8 @@ func isDigestValid(digest [4]byte, genesis time.Time, genValRoot [32]byte) (bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func agentString(pid peer.ID, hst host.Host) string {
|
func agentString(pid peer.ID, hst host.Host) string {
|
||||||
agString := ""
|
|
||||||
ok := false
|
|
||||||
rawVersion, storeErr := hst.Peerstore().Get(pid, "AgentVersion")
|
rawVersion, storeErr := hst.Peerstore().Get(pid, "AgentVersion")
|
||||||
agString, ok = rawVersion.(string)
|
agString, ok := rawVersion.(string)
|
||||||
if storeErr != nil || !ok {
|
if storeErr != nil || !ok {
|
||||||
agString = ""
|
agString = ""
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,6 @@ func (l *List[T]) Remove(n *Node[T]) {
|
|||||||
n.next.prev = n.prev
|
n.next.prev = n.prev
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n = nil
|
|
||||||
l.len--
|
l.len--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ func DeepEqual(loggerFn assertionLoggerFn, expected, actual interface{}, msg ...
|
|||||||
if !isDeepEqual(expected, actual) {
|
if !isDeepEqual(expected, actual) {
|
||||||
errMsg := parseMsg("Values are not equal", msg...)
|
errMsg := parseMsg("Values are not equal", msg...)
|
||||||
_, file, line, _ := runtime.Caller(2)
|
_, file, line, _ := runtime.Caller(2)
|
||||||
diff := ""
|
var diff string
|
||||||
if _, isProto := expected.(proto.Message); isProto {
|
if _, isProto := expected.(proto.Message); isProto {
|
||||||
diff = ProtobufPrettyDiff(expected, actual)
|
diff = ProtobufPrettyDiff(expected, actual)
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,7 +83,7 @@ func optimisticSyncEnabled(_ *types.EvaluationContext, conns ...*grpc.ClientConn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) {
|
func retrieveHeadSlot(resp *beacon.GetBlockV2Response) (uint64, error) {
|
||||||
headSlot := uint64(0)
|
var headSlot uint64
|
||||||
var err error
|
var err error
|
||||||
switch resp.Version {
|
switch resp.Version {
|
||||||
case version.String(version.Phase0):
|
case version.String(version.Phase0):
|
||||||
|
Loading…
Reference in New Issue
Block a user