Fix rddl claim client load (#388)

* fix: lazyLoad on rddl-claim-service-client
* fix: sane default value for claim-host
---------

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2024-04-29 11:49:45 +02:00 committed by GitHub
parent b0f8516cd6
commit 066c1a7667
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -16,13 +16,18 @@ import (
var ClaimServiceClient IRCClient
func init() {
func lazyLoad() IRCClient {
if ClaimServiceClient != nil {
return ClaimServiceClient
}
cfg := config.GetConfig()
ClaimServiceClient = NewRCClient(cfg.ClaimHost, &http.Client{})
return ClaimServiceClient
}
func PostClaim(ctx context.Context, beneficiary string, amount uint64, id uint64) (txID string, err error) {
res, err := ClaimServiceClient.PostClaim(ctx, PostClaimRequest{Beneficiary: beneficiary, Amount: amount, ClaimID: int(id)})
client := lazyLoad()
res, err := client.PostClaim(ctx, PostClaimRequest{Beneficiary: beneficiary, Amount: amount, ClaimID: int(id)})
if err != nil {
return
}

View File

@ -66,7 +66,7 @@ func DefaultConfig() *Config {
MqttPort: 1886,
MqttUser: "user",
MqttPassword: "password",
ClaimHost: "testnet-p2r.rddl.io",
ClaimHost: "https://testnet-p2r.rddl.io",
MqttTLS: true,
}
}