This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
generated from mrz1836/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from BuxOrg/fix-461-arc-fee-quotes
fix(BUX-461) fee quotes for both arc and mAPI with user defined fee quote
- Loading branch information
Showing
24 changed files
with
510 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package chainstate | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/BuxOrg/bux/utils" | ||
"github.com/bitcoin-sv/go-broadcast-client/broadcast" | ||
"github.com/newrelic/go-agent/v3/newrelic" | ||
) | ||
|
||
func (c *Client) broadcastClientInit(ctx context.Context) error { | ||
if txn := newrelic.FromContext(ctx); txn != nil { | ||
defer txn.StartSegment("start_broadcast_client").End() | ||
} | ||
|
||
bc := c.options.config.broadcastClient | ||
if bc == nil { | ||
err := errors.New("broadcast client is not configured") | ||
return err | ||
} | ||
|
||
if c.isFeeQuotesEnabled() { | ||
// get the lowest fee | ||
var feeQuotes []*broadcast.FeeQuote | ||
feeQuotes, err := bc.GetFeeQuote(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
if len(feeQuotes) == 0 { | ||
return errors.New("no fee quotes returned from broadcast client") | ||
} | ||
c.options.logger.Info().Msgf("got %d fee quote(s) from broadcast client", len(feeQuotes)) | ||
fees := make([]utils.FeeUnit, len(feeQuotes)) | ||
for index, fee := range feeQuotes { | ||
fees[index] = utils.FeeUnit{ | ||
Satoshis: int(fee.MiningFee.Satoshis), | ||
Bytes: int(fee.MiningFee.Bytes), | ||
} | ||
} | ||
c.options.config.feeUnit = utils.LowestFee(fees, c.options.config.feeUnit) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.