prysm-pulse/slasher/service/data_update.go

40 lines
1004 B
Go
Raw Normal View History

package service
import (
"time"
ptypes "github.com/gogo/protobuf/types"
"github.com/prysmaticlabs/prysm/shared/params"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// finalisedChangeUpdater this is a stub for the comming PRs #3133
// Store validator index to public key map Validate attestation signature.
func (s *Service) finalisedChangeUpdater() error {
secondsPerSlot := params.BeaconConfig().SecondsPerSlot
d := time.Duration(secondsPerSlot) * time.Second
tick := time.Tick(d)
var finalizedEpoch uint64
for {
select {
case <-tick:
ch, err := s.beaconClient.GetChainHead(s.context, &ptypes.Empty{})
if err != nil {
log.Error(err)
continue
}
if ch != nil {
if ch.FinalizedEpoch > finalizedEpoch {
log.Infof("Finalized epoch %d", ch.FinalizedEpoch)
}
continue
}
log.Error("No chain head was returned by beacon chain.")
case <-s.context.Done():
return status.Error(codes.Canceled, "Stream context canceled")
}
}
}