Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fee estimator from txn construction calls #520

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions routes/access_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ func (fes *APIServer) accessGroupHandler(
accessGroupOwnerPkBytes, accessGroupPkBytes,
accessGroupKeyNameBytes, accessGroupOperationType,
extraData,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
return fmt.Errorf("problem creating transaction: %v", err)
}
Expand Down Expand Up @@ -398,8 +397,7 @@ func (fes *APIServer) accessGroupMemberHandler(
accessGroupOwnerPkBytes, accessGroupKeyNameBytes,
accessGroupMembers, accessGroupMemberOperationType,
extraData,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
return fmt.Errorf("problem creating transaction: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions routes/admin_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (fes *APIServer) UpdateGlobalParams(ww http.ResponseWriter, req *http.Reque
maxNonceExpirationBlockHeightOffset,
extraData,
requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator())
fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("UpdateGlobalParams: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -401,7 +401,7 @@ func (fes *APIServer) SwapIdentity(ww http.ResponseWriter, req *http.Request) {
toPublicKey,

requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator())
fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("SwapIdentity: Problem creating transaction: %v", err))
return
Expand Down
4 changes: 0 additions & 4 deletions routes/associations.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ func (fes *APIServer) CreateUserAssociation(ww http.ResponseWriter, req *http.Re
requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(),
additionalOutputs,
fes.backendServer.GetFeeEstimator(),
)
if err != nil {
_AddInternalServerError(ww, fmt.Sprintf("CreateUserAssociation: problem creating txn: %v", err))
Expand Down Expand Up @@ -338,7 +337,6 @@ func (fes *APIServer) DeleteUserAssociation(ww http.ResponseWriter, req *http.Re
requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(),
additionalOutputs,
fes.backendServer.GetFeeEstimator(),
)
if err != nil {
_AddInternalServerError(ww, fmt.Sprintf("DeleteUserAssociation: problem creating txn: %v", err))
Expand Down Expand Up @@ -806,7 +804,6 @@ func (fes *APIServer) CreatePostAssociation(ww http.ResponseWriter, req *http.Re
requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(),
additionalOutputs,
fes.backendServer.GetFeeEstimator(),
)
if err != nil {
_AddInternalServerError(ww, fmt.Sprintf("CreatePostAssociation: problem creating txn: %v", err))
Expand Down Expand Up @@ -892,7 +889,6 @@ func (fes *APIServer) DeletePostAssociation(ww http.ResponseWriter, req *http.Re
requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(),
additionalOutputs,
fes.backendServer.GetFeeEstimator(),
)
if err != nil {
_AddInternalServerError(ww, fmt.Sprintf("DeletePostAssociation: problem creating txn: %v", err))
Expand Down
15 changes: 8 additions & 7 deletions routes/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (fes *APIServer) APIBalance(ww http.ResponseWriter, rr *http.Request) {
}

// Get all the UTXOs for the public key.
utxoView, err := fes.mempool.GetAugmentedUtxoViewForPublicKey(publicKeyBytes, nil)
utxoView, err := fes.backendServer.GetMempool().GetAugmentedUtxoViewForPublicKey(publicKeyBytes, nil)
if err != nil {
APIAddError(ww, fmt.Sprintf("APIBalanceRequest: Problem getting UTXOs for public key: %v", err))
return
Expand Down Expand Up @@ -776,8 +776,7 @@ func (fes *APIServer) APITransferDeSo(ww http.ResponseWriter, rr *http.Request)
// Create a MAX transaction
txnn, totalInputt, spendAmountt, feeNanoss, err = fes.blockchain.CreateMaxSpend(
senderPublicKeyBytes, recipientPub.SerializeCompressed(), nil,
uint64(minFeeRateNanosPerKB),
fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator())
uint64(minFeeRateNanosPerKB), fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
APIAddError(ww, fmt.Sprintf("APITransferDeSo: Error processing MAX transaction: %v", err))
return
Expand Down Expand Up @@ -980,7 +979,7 @@ func (fes *APIServer) APITransactionInfo(ww http.ResponseWriter, rr *http.Reques
// IsMempool means we should just return all of the transactions that are currently in the mempool.
if transactionInfoRequest.IsMempool {
// Get all the txns from the mempool.
poolTxns := fes.mempool.GetOrderedTransactions()
poolTxns := fes.backendServer.GetMempool().GetOrderedTransactions()

res := &APITransactionInfoResponse{}
res.Transactions = []*TransactionResponse{}
Expand Down Expand Up @@ -1047,7 +1046,7 @@ func (fes *APIServer) APITransactionInfo(ww http.ResponseWriter, rr *http.Reques

if txn == nil {
// Try to look the transaction up in the mempool before giving up.
txnInPool := fes.mempool.GetMempoolTx(txID)
txnInPool := fes.backendServer.GetMempool().GetMempoolTx(txID)
if txnInPool == nil {
APIAddError(ww, fmt.Sprintf("APITransactionInfo: Could not find transaction with TransactionIDBase58Check = %s",
transactionInfoRequest.TransactionIDBase58Check))
Expand Down Expand Up @@ -1162,7 +1161,7 @@ func (fes *APIServer) APITransactionInfo(ww http.ResponseWriter, rr *http.Reques
if transactionInfoRequest.LastPublicKeyTransactionIndex <= 0 {

// Start with the mempool
poolTxns := fes.mempool.GetOrderedTransactions()
poolTxns := fes.backendServer.GetMempool().GetOrderedTransactions()

// Go from most recent to least recent
// TODO: Support pagination for mempool transactions
Expand Down Expand Up @@ -1416,6 +1415,8 @@ func (fes *APIServer) _processTransactionWithKey(
// transaction will be mined at the earliest.
blockHeight+1,
true,
// TODO: Do we want to use fes.backendServer.GetMempool here?
// There are probably other updates we need to make here for PoS as well.
fes.mempool)
if err != nil {
return fmt.Errorf("_processTransactionWithKey: Problem validating txn: %v", err)
Expand Down Expand Up @@ -1449,7 +1450,7 @@ func (fes *APIServer) _augmentAndProcessTransactionWithSubsidyWithKey(
// return an error.
totalInput, spendAmount, changeAmount, fees, err :=
fes.blockchain.AddInputsAndChangeToTransactionWithSubsidy(txn, minFeeRateNanosPerKB,
inputSubsidy, fes.mempool, 0, fes.backendServer.GetFeeEstimator())
inputSubsidy, fes.backendServer.GetMempool(), 0)
if err != nil {
return 0, 0, 0, 0, fmt.Errorf("_augmentAndProcessTransactionWithKey: Problem adding inputs and "+
"change to transaction %v: %v", txn, err)
Expand Down
6 changes: 2 additions & 4 deletions routes/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ func (fes *APIServer) SendMessageStateless(ww http.ResponseWriter, req *http.Req
senderMessagingPublicKey, senderMessagingGroupKeyNameBytes,
recipientMessagingPublicKey, recipientMessagingGroupKeyNameBytes,
tstamp, extraData,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("SendMessageStateless: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -974,8 +973,7 @@ func (fes *APIServer) RegisterMessagingGroupKey(ww http.ResponseWriter, req *htt
txn, totalInput, changeAmount, fees, err := fes.blockchain.CreateMessagingKeyTxn(
ownerPkBytes, messagingPkBytes, messagingKeyNameBytes, messagingKeySignature,
[]*lib.MessagingGroupMember{}, extraData,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("RegisterMessagingGroupKey: Problem creating transaction: %v", err))
return
Expand Down
2 changes: 1 addition & 1 deletion routes/new_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (fes *APIServer) sendMessageHandler(
*lib.NewPublicKey(recipientGroupOwnerPkBytes), *lib.NewGroupKeyName(recipientGroupKeyNameBytes),
*lib.NewPublicKey(recipientAccessGroupPkbytes), hexDecodedEncryptedMessageBytes, tstamp,
newMessageType, newMessageOperationType, extraData, requestData.MinFeeRateNanosPerKB,
fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator())
fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
return errors.Wrapf(err, "Problem creating transaction: ")
}
Expand Down
21 changes: 7 additions & 14 deletions routes/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ func (fes *APIServer) CreateNFT(ww http.ResponseWriter, req *http.Request) {
additionalDESORoyaltiesPubKeyMap,
additionalCoinRoyaltiesPubKeyMap,
extraData,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("CreateNFT: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -412,8 +411,7 @@ func (fes *APIServer) UpdateNFT(ww http.ResponseWriter, req *http.Request) {
uint64(requestData.MinBidAmountNanos),
requestData.IsBuyNow,
requestData.BuyNowPriceNanos,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("UpdateNFT: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -570,8 +568,7 @@ func (fes *APIServer) CreateNFTBid(ww http.ResponseWriter, req *http.Request) {
nftPostHash,
uint64(requestData.SerialNumber),
uint64(requestData.BidAmountNanos),
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("CreateNFTBid: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -734,8 +731,7 @@ func (fes *APIServer) AcceptNFTBid(ww http.ResponseWriter, req *http.Request) {
bidderPKID.PKID,
uint64(requestData.BidAmountNanos),
encryptedUnlockableTextBytes,
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("AcceptNFTBid: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -1653,8 +1649,7 @@ func (fes *APIServer) TransferNFT(ww http.ResponseWriter, req *http.Request) {
nftPostHash,
uint64(requestData.SerialNumber),
[]byte(requestData.EncryptedUnlockableText),
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("TransferNFT: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -1794,8 +1789,7 @@ func (fes *APIServer) AcceptNFTTransfer(ww http.ResponseWriter, req *http.Reques
updaterPublicKeyBytes,
nftPostHash,
uint64(requestData.SerialNumber),
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("AcceptNFTTransfer: Problem creating transaction: %v", err))
return
Expand Down Expand Up @@ -1934,8 +1928,7 @@ func (fes *APIServer) BurnNFT(ww http.ResponseWriter, req *http.Request) {
updaterPublicKeyBytes,
nftPostHash,
uint64(requestData.SerialNumber),
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs,
fes.backendServer.GetFeeEstimator())
requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs)
if err != nil {
_AddBadRequestError(ww, fmt.Sprintf("BurnNFT: Problem creating transaction: %v", err))
return
Expand Down
2 changes: 1 addition & 1 deletion routes/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ func (fes *APIServer) ValidateJWT(publicKey string, jwtToken string) (bool, erro
return nil, errors.Wrapf(err, "Problem parsing derived public key bytes")
}
// Validate the derived public key.
utxoView, err := fes.mempool.GetAugmentedUniversalView()
utxoView, err := fes.backendServer.GetMempool().GetAugmentedUniversalView()
if err != nil {
return nil, errors.Wrapf(err, "Problem getting utxoView")
}
Expand Down
3 changes: 1 addition & 2 deletions routes/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ func (fes *APIServer) SendSeedDeSo(recipientPkBytes []byte, amountNanos uint64,
if utxoView.GlobalParamsEntry != nil && utxoView.GlobalParamsEntry.MinimumNetworkFeeNanosPerKB > 0 {
minFee = utxoView.GlobalParamsEntry.MinimumNetworkFeeNanosPerKB
}
_, _, _, _, err = fes.blockchain.AddInputsAndChangeToTransaction(txn, minFee, fes.mempool,
fes.backendServer.GetFeeEstimator())
_, _, _, _, err = fes.blockchain.AddInputsAndChangeToTransaction(txn, minFee, fes.backendServer.GetMempool())
if err != nil {
return nil, fmt.Errorf("SendSeedDeSo: Error adding inputs for seed DeSo: %v", err)
}
Expand Down
Loading
Loading