Improved payment handling
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
oracleclient "github.com/tech/sendico/fx/oracle/client"
|
||||
chainclient "github.com/tech/sendico/gateway/chain/client"
|
||||
feesv1 "github.com/tech/sendico/pkg/proto/billing/fees/v1"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc"
|
||||
@@ -47,18 +46,12 @@ func (i *Imp) initDependencies(cfg *config) *clientDependencies {
|
||||
}
|
||||
}
|
||||
|
||||
if gatewayAddress := cfg.Gateway.resolveAddress(); gatewayAddress != "" {
|
||||
client, err := chainclient.New(context.Background(), chainclient.Config{
|
||||
Address: gatewayAddress,
|
||||
DialTimeout: cfg.Gateway.dialTimeout(),
|
||||
CallTimeout: cfg.Gateway.callTimeout(),
|
||||
Insecure: cfg.Gateway.InsecureTransport,
|
||||
})
|
||||
if err != nil {
|
||||
i.logger.Warn("Failed to initialise chain gateway client", zap.Error(err), zap.String("address", gatewayAddress))
|
||||
} else {
|
||||
deps.gatewayClient = client
|
||||
}
|
||||
if i != nil && i.discoveryReg != nil {
|
||||
i.discoveryClients = newDiscoveryClientResolver(i.logger, i.discoveryReg)
|
||||
deps.gatewayResolver = discoveryChainGatewayResolver{resolver: i.discoveryClients}
|
||||
deps.gatewayInvokeResolver = discoveryGatewayInvokeResolver{resolver: i.discoveryClients}
|
||||
} else if i != nil && i.logger != nil {
|
||||
i.logger.Warn("Discovery registry unavailable; chain gateway clients disabled")
|
||||
}
|
||||
|
||||
return deps
|
||||
@@ -72,9 +65,9 @@ func (i *Imp) closeDependencies() {
|
||||
_ = i.deps.oracleClient.Close()
|
||||
i.deps.oracleClient = nil
|
||||
}
|
||||
if i.deps.gatewayClient != nil {
|
||||
_ = i.deps.gatewayClient.Close()
|
||||
i.deps.gatewayClient = nil
|
||||
if i.discoveryClients != nil {
|
||||
i.discoveryClients.Close()
|
||||
i.discoveryClients = nil
|
||||
}
|
||||
if i.deps.feesConn != nil {
|
||||
_ = i.deps.feesConn.Close()
|
||||
|
||||
Reference in New Issue
Block a user