chore: update SWQoSClientConfig

This commit is contained in:
2025-12-26 13:38:06 +08:00
parent 5c82f6b298
commit 2c0cbd574a
3 changed files with 5 additions and 4 deletions

View File

@@ -43,8 +43,8 @@ func main() {
blockrazorClient, err := swqos.NewSWQoSClient( blockrazorClient, err := swqos.NewSWQoSClient(
context.Background(), context.Background(),
enum.SWQoSAgentBlockRazor,
&swqos.SWQoSClientConfig{ &swqos.SWQoSClientConfig{
Name: enum.SWQoSAgentBlockRazor,
SendTxUrl: "frankfurt.solana-grpc.blockrazor.xyz:80", SendTxUrl: "frankfurt.solana-grpc.blockrazor.xyz:80",
}) })
if err != nil { if err != nil {

View File

@@ -8,10 +8,10 @@ import (
"github.com/samlior/libsam/pkg/swqos/clients" "github.com/samlior/libsam/pkg/swqos/clients"
) )
func NewSWQoSClient(ctx context.Context, agent string, config *SWQoSClientConfig) (SWQoSClient, error) { func NewSWQoSClient(ctx context.Context, config *SWQoSClientConfig) (SWQoSClient, error) {
var err error var err error
var client SWQoSClient var client SWQoSClient
switch agent { switch config.Name {
case enum.SWQoSAgentBlockRazor: case enum.SWQoSAgentBlockRazor:
client, err = clients.NewBlockRazorClient(ctx, config.SendTxUrl) client, err = clients.NewBlockRazorClient(ctx, config.SendTxUrl)
case enum.SWQoSAgentNextBlock: case enum.SWQoSAgentNextBlock:
@@ -27,7 +27,7 @@ func NewSWQoSClient(ctx context.Context, agent string, config *SWQoSClientConfig
case enum.SWQoSAgent0slot, enum.SWQoSAgentJito, enum.SWQoSAgentHelius, enum.SWQoSAgentNozomi, enum.SWQoSAgentStellium: case enum.SWQoSAgent0slot, enum.SWQoSAgentJito, enum.SWQoSAgentHelius, enum.SWQoSAgentNozomi, enum.SWQoSAgentStellium:
client = clients.NewHttpClient(config.SendTxUrl, config.SendBundleUrl) client = clients.NewHttpClient(config.SendTxUrl, config.SendBundleUrl)
default: default:
return nil, fmt.Errorf("invalid agent: %s", agent) return nil, fmt.Errorf("invalid agent: %s", config.Name)
} }
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -7,6 +7,7 @@ import (
) )
type SWQoSClientConfig struct { type SWQoSClientConfig struct {
Name string `json:"name"`
SendTxUrl string `json:"sendTxUrl"` SendTxUrl string `json:"sendTxUrl"`
SendBundleUrl string `json:"sendBundleUrl"` SendBundleUrl string `json:"sendBundleUrl"`
KeepAliveUrl string `json:"keepAliveUrl"` KeepAliveUrl string `json:"keepAliveUrl"`