Skip to content

Commit

Permalink
feat: prepare updates for base & quote asset definition
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Oct 16, 2024
1 parent 9283456 commit 28397cd
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions node/pkg/admin/config/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"reflect"
"strconv"
"strings"

Expand All @@ -15,6 +16,13 @@ import (
"github.com/rs/zerolog/log"
)

type WsFeedDefinition struct {
Type string `json:"type"`
Provider string `json:"provider"`
Base string `json:"base"`
Quote string `json:"quote"`
}

type BulkConfigs struct {
Configs []ConfigInsertModel `json:"result"`
}
Expand Down Expand Up @@ -108,6 +116,28 @@ func sync(ctx context.Context) error {
log.Info().Str("Player", "Config").Str("Feed", dbFeed.Name).Msg("Feed not found in config")
removingFeeds = append(removingFeeds, strconv.Itoa(int(*dbFeed.ID)))
}

if strings.Contains(dbFeed.Name, "wss") {
var feedDefinitionFromDB, feedDefinitonFromConfig WsFeedDefinition

err = json.Unmarshal(dbFeed.Definition, &feedDefinitionFromDB)
if err != nil {
log.Error().Err(err).Str("Player", "Admin").Msg("failed to unmarshal feed definition from db")
return err
}

err = json.Unmarshal(loadedFeedMap[dbFeed.Name].Definition, &feedDefinitonFromConfig)
if err != nil {
log.Error().Err(err).Str("Player", "Admin").Msg("failed to unmarshal feed definition from config")
return err
}

if !reflect.DeepEqual(feedDefinitionFromDB, feedDefinitonFromConfig) {
log.Info().Str("Player", "Config").Str("Feed", dbFeed.Name).Msg("Feed definition not found in config")
removingFeeds = append(removingFeeds, strconv.Itoa(int(*dbFeed.ID)))
}
}

}
log.Debug().Str("Player", "Admin").Msg("removingFeeds: " + strings.Join(removingFeeds, ","))

Expand Down

0 comments on commit 28397cd

Please sign in to comment.