mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
0c3586a8ea
* Add proto array fork choice object to RPC * Add pb * Add pb * Expose proto array store object * Test * Merge branch 'forkchoice-endpoint' of github.com:prysmaticlabs/prysm into forkchoice-endpoint * s/Nodes/nodes * Remove proto from gitignore * More implementations of GetProtoArrayForkChoice * Comments * Use hex * Gazelle * GetForkChoice Test * Remove pb.go * Merge branch 'master' into forkchoice-endpoint * Typo, thanks Raul! * Merge branch 'forkchoice-endpoint' of github.com:prysmaticlabs/prysm into forkchoice-endpoint
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package debug
|
|
|
|
import (
|
|
"context"
|
|
"encoding/hex"
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
pbrpc "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
|
|
)
|
|
|
|
// GetProtoArrayForkChoice returns proto array fork choice store.
|
|
func (ds *Server) GetProtoArrayForkChoice(ctx context.Context, _ *ptypes.Empty) (*pbrpc.ProtoArrayForkChoiceResponse, error) {
|
|
store := ds.HeadFetcher.ProtoArrayStore()
|
|
|
|
nodes := store.Nodes
|
|
returnedNodes := make([]*pbrpc.ProtoArrayNode, len(nodes))
|
|
|
|
for i := 0; i < len(returnedNodes); i++ {
|
|
returnedNodes[i] = &pbrpc.ProtoArrayNode{
|
|
Slot: nodes[i].Slot,
|
|
Root: nodes[i].Root[:],
|
|
Parent: nodes[i].Parent,
|
|
JustifiedEpoch: nodes[i].JustifiedEpoch,
|
|
FinalizedEpoch: nodes[i].FinalizedEpoch,
|
|
Weight: nodes[i].Weight,
|
|
BestChild: nodes[i].BestChild,
|
|
BestDescendant: nodes[i].BestDescendent,
|
|
}
|
|
}
|
|
|
|
indices := make(map[string]uint64)
|
|
for k, v := range store.NodeIndices {
|
|
indices[hex.EncodeToString(k[:])] = v
|
|
}
|
|
|
|
return &pbrpc.ProtoArrayForkChoiceResponse{
|
|
PruneThreshold: store.PruneThreshold,
|
|
JustifiedEpoch: store.JustifiedEpoch,
|
|
FinalizedEpoch: store.FinalizedEpoch,
|
|
ProtoArrayNodes: returnedNodes,
|
|
Indices: indices,
|
|
}, nil
|
|
}
|