From ff9ce7296979f41387964315e0dc502ebe8f7b98 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf <1028334+nikhilsaraf@users.noreply.github.com> Date: Wed, 12 Feb 2020 13:29:09 -0800 Subject: [PATCH] Revert "Upgrade horizonclient to v2 to fix horizon v1 API changes (closes #360) (#362)" This reverts commit ba198426b99e7919a16ec998503ec5d0143d38bf. --- glide.lock | 12 +++--------- glide.yaml | 2 +- plugins/sdexExtensions.go | 40 +++++++++++++++++++-------------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/glide.lock b/glide.lock index f22157def..657e70066 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: fe2cef8cdfc3bbdd1aff4bf40700c445c2e5f8dd33e3199e95717c8faedaa498 -updated: 2020-02-07T16:46:11.373155-08:00 +hash: 7008afae44e3682dc2db084f221f7e2d4bf48676c162ed45125bec94cb03dab5 +updated: 2019-11-22T12:43:28.938450375+05:30 imports: - name: cloud.google.com/go version: 83a0b8742b4d7302c26d3b71bfdcbd9224f6b951 @@ -61,8 +61,6 @@ imports: version: c8c88dbee036db4e4808d1f2ec8c2e15e11c3f80 subpackages: - query -- name: github.com/gorilla/schema - version: 61751c9687439bf8cd824ad7eec0d21db1a1b804 - name: github.com/hashicorp/hcl version: 914dc3f8dd7c463188c73fc47e9ced82a6e421ca subpackages: @@ -145,11 +143,10 @@ imports: - name: github.com/spf13/viper version: 01d7d76eb0020ae2fd1275899065ddfdd9f6a528 - name: github.com/stellar/go - version: 7e6a2fc068c82638b19f4ce4fdfb23ad28ec6709 + version: a599ed95b928a7bdcee21cee4999efd05e43c2df subpackages: - amount - build - - clients/horizon - clients/horizonclient - crc16 - hash @@ -161,11 +158,8 @@ imports: - protocols/horizon/effects - protocols/horizon/operations - strkey - - support/app - - support/clock - support/config - support/errors - - support/http/httpdecode - support/log - support/render/hal - support/render/httpjson diff --git a/glide.yaml b/glide.yaml index 2f28bc941..0ab5a7142 100644 --- a/glide.yaml +++ b/glide.yaml @@ -9,7 +9,7 @@ import: - package: github.com/spf13/pflag version: v1.0.0 - package: github.com/stellar/go - version: release-horizonclient-v2.1.0 + version: a599ed95b928a7bdcee21cee4999efd05e43c2df subpackages: - build - clients/horizonclient diff --git a/plugins/sdexExtensions.go b/plugins/sdexExtensions.go index 0e136a6de..70fdcf08b 100644 --- a/plugins/sdexExtensions.go +++ b/plugins/sdexExtensions.go @@ -71,44 +71,44 @@ func getFeeFromStats(horizonClient horizonclient.ClientInterface, capacityTrigge } // parse percentile value - maxFee, e := getMaxFee(&feeStats, percentile) + acceptedFee, e := getAcceptedFee(&feeStats, percentile) if e != nil { - return 0, fmt.Errorf("could not fetch max fee: %s", e) + return 0, fmt.Errorf("could not fetch accepted fee: %s", e) } - maxFeeInt64 := uint64(maxFee) + acceptedFeeInt64 := uint64(acceptedFee) - if maxFeeInt64 <= maxOpFeeStroops { - log.Printf("maxFeeInt64 <= maxOpFeeStroops; using maxFee of %d stroops at percentile=%d (maxOpFeeStroops=%d)\n", maxFeeInt64, percentile, maxOpFeeStroops) - return maxFeeInt64, nil + if acceptedFeeInt64 <= maxOpFeeStroops { + log.Printf("acceptedFeeInt64 <= maxOpFeeStroops; using acceptedFee of %d stroops at percentile=%d (maxOpFeeStroops=%d)\n", acceptedFeeInt64, percentile, maxOpFeeStroops) + return acceptedFeeInt64, nil } - log.Printf("maxFeeInt64 > maxOpFeeStroops; using maxOpFeeStroops of %d stroops (percentile=%d, maxFee=%d stroops)\n", maxOpFeeStroops, percentile, maxFeeInt64) + log.Printf("acceptedFeeInt64 > maxOpFeeStroops; using maxOpFeeStroops of %d stroops (percentile=%d, acceptedFee=%d stroops)\n", maxOpFeeStroops, percentile, acceptedFeeInt64) return maxOpFeeStroops, nil } -func getMaxFee(fs *hProtocol.FeeStats, percentile uint8) (int64, error) { +func getAcceptedFee(fs *hProtocol.FeeStats, percentile uint8) (int, error) { switch percentile { case 10: - return fs.MaxFee.P10, nil + return fs.P10AcceptedFee, nil case 20: - return fs.MaxFee.P20, nil + return fs.P20AcceptedFee, nil case 30: - return fs.MaxFee.P30, nil + return fs.P30AcceptedFee, nil case 40: - return fs.MaxFee.P40, nil + return fs.P40AcceptedFee, nil case 50: - return fs.MaxFee.P50, nil + return fs.P50AcceptedFee, nil case 60: - return fs.MaxFee.P60, nil + return fs.P60AcceptedFee, nil case 70: - return fs.MaxFee.P70, nil + return fs.P70AcceptedFee, nil case 80: - return fs.MaxFee.P80, nil + return fs.P80AcceptedFee, nil case 90: - return fs.MaxFee.P90, nil + return fs.P90AcceptedFee, nil case 95: - return fs.MaxFee.P95, nil + return fs.P95AcceptedFee, nil case 99: - return fs.MaxFee.P99, nil + return fs.P99AcceptedFee, nil } - return 0, fmt.Errorf("unable to get max fee for percentile: %d", percentile) + return 0, fmt.Errorf("unable to get accepted fee for percentile: %d", percentile) }