prysm-pulse/slasher/service/data_update.go
shayzluf d93ec64b21 Slasher Grpc client (#4230)
* grpc connection
* fix order
* Merge branch 'fixInteropGenesis' of https://github.com/prysmaticlabs/prysm into grpc_client
* gaz
* grpc setup
* running version
* added comments
* Merge branch 'master' of github.com:prysmaticlabs/prysm into grpc_client
* fix test
* terence feedback
* terence feedback
* feedback changes
* feedback changes
* comment fix
* Merge branch 'master' of github.com:prysmaticlabs/prysm into grpc_client
* logging when there is no chain head
* rename function
* terence and nishant feedback
* fix imports
* nishant feedback
* fix wait for stop
* fix imports
* fix tests
2019-12-13 07:31:37 +00:00

40 lines
1004 B
Go

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")
}
}
}