Skip to content

Commit

Permalink
RPC: Use the proper db access level, use head root from head fetcher (#…
Browse files Browse the repository at this point in the history
…4752)

* Use the proper db access level, use head root from head fetcher
* Reuse head root
  • Loading branch information
prestonvanloon committed Feb 5, 2020
1 parent 8ad174f commit 9958afe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions beacon-chain/rpc/validator/attester.go
Expand Up @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/validator/server.go
Expand Up @@ -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
Expand Down

0 comments on commit 9958afe

Please sign in to comment.