RPC: Use the proper db access level, use head root from head fetcher (#4752)

* Use the proper db access level, use head root from head fetcher
* Reuse head root
This commit is contained in:
Preston Van Loon 2020-02-05 00:50:07 -08:00 committed by GitHub
parent 8ad174ffd8
commit 9958afe79d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 10 deletions

View File

@ -85,15 +85,7 @@ func (vs *Server) GetAttestationData(ctx context.Context, req *ethpb.Attestation
return nil, status.Errorf(codes.Internal, "Could not get target block for slot %d: %v", epochStartSlot, err)
}
if bytesutil.ToBytes32(targetRoot) == params.BeaconConfig().ZeroHash {
b, err := vs.BeaconDB.HeadBlock(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get head block: %v", err)
}
r, err := ssz.HashTreeRoot(b.Block)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not hash head block: %v", err)
}
targetRoot = r[:]
targetRoot = headRoot
}
}

View File

@ -38,7 +38,7 @@ func init() {
// and more.
type Server struct {
Ctx context.Context
BeaconDB db.HeadAccessDatabase
BeaconDB db.NoHeadAccessDatabase
AttestationCache *cache.AttestationCache
HeadFetcher blockchain.HeadFetcher
ForkFetcher blockchain.ForkFetcher