From 76258e5fc60aae4f2ce6ad13011e6b916288686a Mon Sep 17 00:00:00 2001 From: Clara van Staden Date: Tue, 16 Apr 2024 09:47:25 +0200 Subject: [PATCH] use provided config file for beacon store (#1180) --- relayer/cmd/store_beacon_state.go | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/relayer/cmd/store_beacon_state.go b/relayer/cmd/store_beacon_state.go index c88cc4248d..9e5468cce3 100644 --- a/relayer/cmd/store_beacon_state.go +++ b/relayer/cmd/store_beacon_state.go @@ -24,14 +24,8 @@ func storeBeaconState() *cobra.Command { RunE: storeBeaconStateInDB, } - cmd.Flags().String("url", "", "URL to generate test fixtures from") - err := cmd.MarkFlagRequired("url") - if err != nil { - return nil - } - - cmd.Flags().String("db-store-location", "", "where the database store file should be stored") - err = cmd.MarkFlagRequired("db-store-location") + cmd.Flags().String("config", "", "path to the beacon config file to use") + err := cmd.MarkFlagRequired("config") if err != nil { return nil } @@ -40,17 +34,12 @@ func storeBeaconState() *cobra.Command { } func storeBeaconStateInDB(cmd *cobra.Command, _ []string) error { - dbStoreLocation, err := cmd.Flags().GetString("db-store-location") - if err != nil { - return err - } - - url, err := cmd.Flags().GetString("url") + configFile, err := cmd.Flags().GetString("config") if err != nil { return err } - viper.SetConfigFile("web/packages/test/config/beacon-relay.json") + viper.SetConfigFile(configFile) if err := viper.ReadInConfig(); err != nil { return err } @@ -60,10 +49,10 @@ func storeBeaconStateInDB(cmd *cobra.Command, _ []string) error { return err } - store := store.New(dbStoreLocation, 100) + store := store.New(conf.Source.Beacon.DataStore.Location, conf.Source.Beacon.DataStore.MaxEntries) specSettings := conf.Source.Beacon.Spec - beaconClient := api.NewBeaconClient(url, specSettings.SlotsInEpoch) + beaconClient := api.NewBeaconClient(conf.Source.Beacon.Endpoint, specSettings.SlotsInEpoch) syncer := syncer.New(beaconClient, specSettings, &store) err = store.Connect()