Fixed validator pubkey -> index getter (#3361)

This commit is contained in:
terence tsao 2019-08-30 13:50:21 -07:00 committed by GitHub
parent 95c528f0bc
commit 314bc513af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package kv package kv
import ( import (
"bytes"
"context" "context"
"encoding/binary" "encoding/binary"
"time" "time"
@ -99,12 +98,8 @@ func (k *Store) ValidatorIndex(ctx context.Context, publicKey [48]byte) (uint64,
if enc == nil { if enc == nil {
return nil return nil
} }
var err error validatorIdx = binary.LittleEndian.Uint64(enc)
buf := bytes.NewBuffer(enc)
validatorIdx, err = binary.ReadUvarint(buf)
if err != nil {
return err
}
ok = true ok = true
return nil return nil
}) })

View File

@ -279,7 +279,7 @@ func (bs *BeaconChainServer) ListValidatorBalances(
return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err)
} }
if !ok { if !ok {
return nil, status.Errorf(codes.Internal, "could validator index for public key %#x not found", pubKey) return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", pubKey)
} }
} }
@ -400,7 +400,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments(
return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err)
} }
if !ok { if !ok {
return nil, status.Errorf(codes.Internal, "could validator index for public key %#x not found", pubKey) return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", pubKey)
} }
} }

View File

@ -95,7 +95,7 @@ func (vs *ValidatorServer) ValidatorIndex(ctx context.Context, req *pb.Validator
return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err)
} }
if !ok { if !ok {
return nil, status.Errorf(codes.Internal, "could validator index for public key %#x not found", req.PublicKey) return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", req.PublicKey)
} }
} }
return &pb.ValidatorIndexResponse{Index: uint64(index)}, nil return &pb.ValidatorIndexResponse{Index: uint64(index)}, nil
@ -125,7 +125,7 @@ func (vs *ValidatorServer) ValidatorPerformance(
return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err)
} }
if !ok { if !ok {
return nil, status.Errorf(codes.Internal, "could validator index for public key %#x not found", req.PublicKey) return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", req.PublicKey)
} }
headState = vs.chainService.(blockchain.HeadRetriever).HeadState() headState = vs.chainService.(blockchain.HeadRetriever).HeadState()
@ -238,7 +238,7 @@ func (vs *ValidatorServer) assignment(
return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err)
} }
if !ok { if !ok {
return nil, status.Errorf(codes.Internal, "could validator index for public key %#x not found", pubkey) return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", pubkey)
} }
} }