Return cloned state (#3351)

This commit is contained in:
terence tsao
2019-08-29 07:36:43 -07:00
committed by Raul Jordan
parent 816aac82d5
commit 206222c5bc
2 changed files with 3 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ go_library(
"//shared/featureconfig:go_default_library",
"//shared/hashutil:go_default_library",
"//shared/params:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@io_k8s_client_go//tools/cache:go_default_library",

View File

@@ -4,6 +4,7 @@ import (
"errors"
"sync"
"github.com/gogo/protobuf/proto"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
@@ -91,7 +92,7 @@ func (c *CheckpointStateCache) StateByCheckpoint(cp *ethpb.Checkpoint) (*pb.Beac
return nil, ErrNotCheckpointState
}
return info.State, nil
return proto.Clone(info.State).(*pb.BeaconState), nil
}
// AddCheckpointState adds CheckpointState object to the cache. This method also trims the least