Skip to content

Commit

Permalink
Retries, backoff and backoff limit implemented on swaps (#49)
Browse files Browse the repository at this point in the history
Retries, backoff and backoff limit for retrying swaps
---------

Co-authored-by: José A.P <[email protected]>
Co-authored-by: José A.P <[email protected]>
  • Loading branch information
3 people authored Sep 12, 2023
1 parent 9aa8e2f commit b6718ee
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 136 deletions.
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"env": {
"LNDCONNECTURIS": "lndconnect://127.0.0.1:10003?cert=MIICJTCCAcygAwIBAgIQLYfp6m1vP9wFBXOcE-UsaDAKBggqhkjOPQQDAjAxMR8wHQYDVQQKExZsbmQgYXV0b2dlbmVyYXRlZCBjZXJ0MQ4wDAYDVQQDEwVjYXJvbDAeFw0yMzAzMjkxNTM4MjBaFw0yNDA1MjMxNTM4MjBaMDExHzAdBgNVBAoTFmxuZCBhdXRvZ2VuZXJhdGVkIGNlcnQxDjAMBgNVBAMTBWNhcm9sMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEcXT4dekJnAiZWd8Pk3FgL1BSFXMRwLGSAlk7Di5hIJnIA1B_o8RWKzlPz7u3Aw5mmWHhN8B2MWMylWlWB2130KOBxTCBwjAOBgNVHQ8BAf8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH_BAUwAwEB_zAdBgNVHQ4EFgQUDOS-19_0LFGf62WRyaaUSLc3j98wawYDVR0RBGQwYoIFY2Fyb2yCCWxvY2FsaG9zdIIFY2Fyb2yCDnBvbGFyLW4xLWNhcm9sggR1bml4ggp1bml4cGFja2V0ggdidWZjb25uhwR_AAABhxAAAAAAAAAAAAAAAAAAAAABhwSsFQAFMAoGCCqGSM49BAMCA0cAMEQCHxYe59PCXrTtSmGsOjfQo6V-sS8j73cqWOzTQbvgI3gCIQCj7sOxnZWBwilec7t8bBXjwPgX9frv8408JW4QhNFOUg&macaroon=AgEDbG5kAvgBAwoQHsW2NwwWb2yOKFMWQQkUWhIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgjpV-eOw554EPrSXPxDhQuOnnwHmEO47Hu1Uiu6EiMNY",
"POLLINGINTERVAL": "5s",
"RETRIESBEFOREBACKOFF": "3",
"BACKOFFCOEFFICIENT": "0.99",
"BACKOFFLIMIT": "0.1",
"LOGLEVEL": "DEBUG",
"LOGFORMAT": "text",
"NODEGUARDHOST": "localhost:50051",
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile.loopserver
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM --platform=linux/amd64 lightninglabs/loopserver:v0.9.123-beta
FROM lightninglabs/loopserver:v0.9.147-beta

COPY regtest.polar/volumes/lnd/alice /root/.lnd
# COPY regtest.polar/volumes/lnd/alice /root/.lnd

USER root
# USER root

RUN chmod -R 777 /root/.lnd
RUN chown -R loopserver:loopserver /root/.lnd
# RUN chmod -R 777 /root/.lnd
# RUN chown -R loopserver:loopserver /root/.lnd

USER loopserver
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ services:
- "11009:11009"
extra_hosts:
- "alice:host-gateway"
#image: lightninglabs/loopserver:v0.9.77-beta
image: loopserver
platform: linux/amd64
image: lightninglabs/loopserver:v0.9.147-beta
restart: unless-stopped
networks:
- regtest
Expand Down
22 changes: 21 additions & 1 deletion flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ THE SOFTWARE.
package main

import (
log "github.com/sirupsen/logrus"
"os"
"strings"

log "github.com/sirupsen/logrus"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -100,12 +101,29 @@ func init() {
rootCmd.Flags().String("swapPublicationOffset", "30m", "Swap publication deadline offset (Maximum time for the swap provider to publish the swap)")
viper.BindPFlag("swapPublicationOffset", rootCmd.Flags().Lookup("swapPublicationOffset"))

// Retries before applying backoff to the swap
rootCmd.Flags().Int("retriesBeforeBackoff", 3, "Number of retries before applying backoff to the swap")
viper.BindPFlag("retriesBeforeBackoff", rootCmd.Flags().Lookup("retriesBeforeBackoff"))

// Coefficient to apply to the backoff
rootCmd.Flags().Float64("backoffCoefficient", 0.95, "Coefficient to apply to the backoff")
viper.BindPFlag("backoffCoefficient", rootCmd.Flags().Lookup("backoffCoefficient"))

// Limit coefficient of the backoff
rootCmd.Flags().Float64("backoffLimit", 0.1, "Limit coefficient of the backoff")
viper.BindPFlag("backoffLimit", rootCmd.Flags().Lookup("backoffLimit"))

//Now we set the global vars

pollingInterval = viper.GetDuration("pollingInterval")
nodeguardHost = viper.GetString("nodeguardHost")
loopdconnectURIs = strings.Split(viper.GetString("loopdconnecturis"), ",")
lndconnectURIs = strings.Split(viper.GetString("lndconnecturis"), ",")

retries = viper.GetInt("retriesBeforeBackoff")
backoffCoefficient = viper.GetFloat64("backoffCoefficient")
backoffLimit = viper.GetFloat64("backoffLimit")

//Set log level and format

logLevel, err := log.ParseLevel(viper.GetString("logLevel"))
Expand All @@ -129,5 +147,7 @@ func init() {
log.Debug("logLevel: ", logLevel)
log.Debug("logFormat: ", viper.GetString("logFormat"))
log.Debug("nodeguardHost: ", nodeguardHost)
log.Debug("retriesBeforeBackoff: ", viper.GetInt("retriesBeforeBackoff"))
log.Debug("backoffCoefficient: ", viper.GetFloat64("backoffCoefficient"))

}
Loading

0 comments on commit b6718ee

Please sign in to comment.