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
|
|
|
|
2021-09-21 19:59:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
2021-07-21 21:34:07 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-05-17 18:32:04 +00:00
|
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
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.
|
2021-05-17 18:32:04 +00:00
|
|
|
func (bs *Server) GetBeaconConfig(_ context.Context, _ *emptypb.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
|
|
|
}
|