Skip to content

Commit a3732ec

Browse files
authored
refactor(chainsync): always initialize kupoUrl from global config (#473)
Signed-off-by: Ales Verbic <[email protected]>
1 parent 54599d3 commit a3732ec

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

input/chainsync/chainsync.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/SundaeSwap-finance/kugo"
3131
"github.com/SundaeSwap-finance/ogmigo/v6/ouroboros/chainsync"
3232
"github.com/blinklabs-io/adder/event"
33+
"github.com/blinklabs-io/adder/internal/config"
3334
"github.com/blinklabs-io/adder/internal/logging"
3435
"github.com/blinklabs-io/adder/plugin"
3536
ouroboros "github.com/blinklabs-io/gouroboros"
@@ -97,6 +98,8 @@ func New(options ...ChainSyncOptionFunc) *ChainSync {
9798
intersectPoints: []ocommon.Point{},
9899
status: &ChainSyncStatus{},
99100
}
101+
// Use Kupo URL from global config
102+
c.kupoUrl = config.GetConfig().KupoUrl
100103
for _, option := range options {
101104
option(c)
102105
}

input/chainsync/options.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ func WithBulkMode(bulkMode bool) ChainSyncOptionFunc {
108108
return func(c *ChainSync) {}
109109
}
110110

111-
// WithKupoUrl specifies the URL for a Kupo instance that will be queried for additional information
112-
func WithKupoUrl(kupoUrl string) ChainSyncOptionFunc {
113-
return func(c *ChainSync) {
114-
c.kupoUrl = kupoUrl
115-
}
116-
}
117-
118111
// WithDelayConfirmationCount specifies the number of confirmations (subsequent blocks) are required before an event will be emitted
119112
func WithDelayConfirmations(count uint) ChainSyncOptionFunc {
120113
return func(c *ChainSync) {

input/chainsync/plugin.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ var cmdlineOptions struct {
3535
intersectPoint string
3636
includeCbor bool
3737
autoReconnect bool
38-
kupoUrl string
3938
delayConfirmations uint
4039
}
4140

@@ -112,13 +111,6 @@ func init() {
112111
DefaultValue: true,
113112
Dest: &(cmdlineOptions.autoReconnect),
114113
},
115-
{
116-
Name: "kupo-url",
117-
Type: plugin.PluginOptionTypeString,
118-
Description: "kupo-url address",
119-
DefaultValue: "",
120-
Dest: &(cmdlineOptions.kupoUrl),
121-
},
122114
{
123115
Name: "delay-confirmations",
124116
Type: plugin.PluginOptionTypeUint,
@@ -149,7 +141,6 @@ func NewFromCmdlineOptions() plugin.Plugin {
149141
WithNtcTcp(cmdlineOptions.ntcTcp),
150142
WithIncludeCbor(cmdlineOptions.includeCbor),
151143
WithAutoReconnect(cmdlineOptions.autoReconnect),
152-
WithKupoUrl(cmdlineOptions.kupoUrl),
153144
WithDelayConfirmations(cmdlineOptions.delayConfirmations),
154145
}
155146
if cmdlineOptions.intersectPoint != "" {

internal/config/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type Config struct {
3838
Input string `yaml:"input" envconfig:"INPUT"`
3939
Output string `yaml:"output" envconfig:"OUTPUT"`
4040
Plugin map[string]map[string]map[any]any `yaml:"plugins"`
41+
KupoUrl string `yaml:"kupo_url" envconfig:"KUPO_URL"`
4142
}
4243

4344
type ApiConfig struct {
@@ -67,8 +68,9 @@ var globalConfig = &Config{
6768
ListenAddress: "localhost",
6869
ListenPort: 0,
6970
},
70-
Input: DefaultInputPlugin,
71-
Output: DefaultOutputPlugin,
71+
Input: DefaultInputPlugin,
72+
Output: DefaultOutputPlugin,
73+
KupoUrl: "",
7274
}
7375

7476
func (c *Config) Load(configFile string) error {

0 commit comments

Comments
 (0)