Created
February 13, 2020 13:00
-
-
Save guybrush/635195e8fc8e453874a1782c4e3548ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test9(addr string) { | |
dialOpt := grpc.WithInsecure() | |
conn, err := grpc.Dial(addr, dialOpt) | |
if err != nil { | |
panic(err) | |
} | |
chainClient := ethpb.NewBeaconChainClient(conn) | |
for _, epoch := range []uint64{50, 100, 1000, 7000} { | |
fmt.Printf("checking epoch %v\n", epoch) | |
var totalEffectiveBalance uint64 | |
validatorsResponse := ðpb.Validators{} | |
for { | |
validatorsResponse, err = chainClient.ListValidators( | |
context.Background(), | |
ðpb.ListValidatorsRequest{ | |
PageToken: validatorsResponse.NextPageToken, | |
PageSize: 500, | |
QueryFilter: ðpb.ListValidatorsRequest_Epoch{Epoch: epoch}, | |
}, | |
) | |
if err != nil { | |
panic(err) | |
} | |
if validatorsResponse.TotalSize == 0 { | |
break | |
} | |
for _, validator := range validatorsResponse.ValidatorList { | |
if validator.Validator.ActivationEpoch > epoch || | |
validator.Validator.ActivationEligibilityEpoch > epoch || | |
validator.Validator.ExitEpoch <= epoch { | |
fmt.Printf("%v %v %v\n", validator.Index, validator.Validator.ActivationEpoch, validator.Validator.ActivationEligibilityEpoch) | |
} | |
totalEffectiveBalance += validator.Validator.EffectiveBalance | |
} | |
if validatorsResponse.NextPageToken == "" { | |
break | |
} | |
} | |
validatorParticipation, err := chainClient.GetValidatorParticipation( | |
context.Background(), | |
ðpb.GetValidatorParticipationRequest{ | |
QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{Epoch: epoch}, | |
}, | |
) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("totalEffectiveBalance: %v\n", totalEffectiveBalance) | |
fmt.Printf("eligibleEther : %v\n", validatorParticipation.Participation.EligibleEther) | |
fmt.Printf("votedEther : %v\n", validatorParticipation.Participation.VotedEther) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment