2020-01-30 19:46:38 +00:00
|
|
|
package beacon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-02-04 05:28:35 +00:00
|
|
|
"fmt"
|
|
|
|
"reflect"
|
2020-01-30 19:46:38 +00:00
|
|
|
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
2020-02-04 05:28:35 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
2020-01-30 19:46:38 +00:00
|
|
|
)
|
|
|
|
|
2020-02-04 05:28:35 +00:00
|
|
|
// GetBeaconConfig retrieves the current configuration parameters of the beacon chain.
|
2020-01-30 19:46:38 +00:00
|
|
|
func (bs *Server) GetBeaconConfig(ctx context.Context, _ *ptypes.Empty) (*ethpb.BeaconConfig, error) {
|
2020-02-04 05:28:35 +00:00
|
|
|
conf := params.BeaconConfig()
|
|
|
|
val := reflect.ValueOf(conf).Elem()
|
|
|
|
numFields := val.Type().NumField()
|
|
|
|
res := make(map[string]string, numFields)
|
|
|
|
for i := 0; i < numFields; i++ {
|
|
|
|
res[val.Type().Field(i).Name] = fmt.Sprintf("%v", val.Field(i).Interface())
|
|
|
|
}
|
|
|
|
return ðpb.BeaconConfig{
|
|
|
|
Config: res,
|
|
|
|
}, nil
|
2020-01-30 19:46:38 +00:00
|
|
|
}
|