mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
clone read access to head state and block (#3350)
This commit is contained in:
parent
9e5864fc61
commit
816aac82d5
@ -27,6 +27,7 @@ go_library(
|
||||
"//proto/eth/v1alpha1:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
"@com_github_gogo_protobuf//proto:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
|
||||
|
@ -3,6 +3,7 @@ package blockchain
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
||||
)
|
||||
@ -57,12 +58,12 @@ func (c *ChainService) HeadRoot() []byte {
|
||||
|
||||
// HeadBlock returns the head block of the chain.
|
||||
func (c *ChainService) HeadBlock() *ethpb.BeaconBlock {
|
||||
return c.headBlock
|
||||
return proto.Clone(c.headBlock).(*ethpb.BeaconBlock)
|
||||
}
|
||||
|
||||
// HeadState returns the head state of the chain.
|
||||
func (c *ChainService) HeadState() *pb.BeaconState {
|
||||
return c.headState
|
||||
return proto.Clone(c.headState).(*pb.BeaconState)
|
||||
}
|
||||
|
||||
// CanonicalRoot returns the canonical root of a given slot.
|
||||
|
@ -212,7 +212,6 @@ func (c *ChainService) saveHead(ctx context.Context, b *ethpb.BeaconBlock, r [32
|
||||
"slots": b.Slot,
|
||||
"root": hex.EncodeToString(r[:]),
|
||||
}).Debug("Saved head info")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user