Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
when setting fee if endpoint is not available (eg: custom network) th…
Browse files Browse the repository at this point in the history
…en use maxOpFeeStroops
  • Loading branch information
nikhilsaraf committed May 4, 2020
1 parent 9884a04 commit 5e8085c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/sdexExtensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plugins
import (
"fmt"
"log"
"strings"

"github.com/stellar/go/clients/horizonclient"
hProtocol "github.com/stellar/go/protocols/horizon"
Expand Down Expand Up @@ -56,6 +57,12 @@ func SdexFeeFnFromStats(
func getFeeFromStats(horizonClient horizonclient.ClientInterface, capacityTrigger float64, percentile uint8, maxOpFeeStroops uint64) (uint64, error) {
feeStats, e := horizonClient.FeeStats()
if e != nil {
// if the endpoint is not available (horizon-specific error) then use the maxOpFeeStroops
// the Stellar network will use the base fee and increase it when necessary up to a max of the fee specified
if strings.Contains(e.Error(), "Endpoint Not Available") {
log.Printf("endpoint was not available so using maxOpFeeStroops passed in of %d stroops\n", maxOpFeeStroops)
return maxOpFeeStroops, nil
}
return 0, fmt.Errorf("error fetching fee stats: %s", e)
}

Expand Down

0 comments on commit 5e8085c

Please sign in to comment.