mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-26 23:46:08 +00:00
* RPC: include orphans into mempool entries * no need for + 1 * give request option to choose mempool pool(s) * add to wallet, fix bg * use orphanpool rpc to test for orphans * fix fmt * fix crash when quering orphan pool in get_mempool_entries * pass the tests, fix fromAppMessage bug * Update config_test.go don't think this is needed * needed for tests to pass * inverse to transactionpoolfilter, cut down code to two ifs. * fmt * update test to true false, forgot one includetransactionpool renaming * update and simplyfiy get_mempool_entry handler * comment outdated * i think we usually use make instead of var. * Fix some leftovers of includeTransactionPool Co-authored-by: Ori Newman <orinewman1@gmail.com>
49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
package rpchandlers
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/transactionid"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
|
)
|
|
|
|
// HandleGetMempoolEntry handles the respectively named RPC command
|
|
func HandleGetMempoolEntry(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
|
|
|
|
transaction := &externalapi.DomainTransaction{}
|
|
var found bool
|
|
var isOrphan bool
|
|
|
|
getMempoolEntryRequest := request.(*appmessage.GetMempoolEntryRequestMessage)
|
|
|
|
transactionID, err := transactionid.FromString(getMempoolEntryRequest.TxID)
|
|
if err != nil {
|
|
errorMessage := &appmessage.GetMempoolEntryResponseMessage{}
|
|
errorMessage.Error = appmessage.RPCErrorf("Transaction ID could not be parsed: %s", err)
|
|
return errorMessage, nil
|
|
}
|
|
|
|
if !getMempoolEntryRequest.FilterTransactionPool {
|
|
transaction, found = context.Domain.MiningManager().GetTransaction(transactionID)
|
|
}
|
|
|
|
if getMempoolEntryRequest.IncludeOrphanPool && !found {
|
|
transaction, found = context.Domain.MiningManager().GetOrphanTransaction(transactionID)
|
|
isOrphan = true
|
|
}
|
|
|
|
if !found {
|
|
errorMessage := &appmessage.GetMempoolEntryResponseMessage{}
|
|
errorMessage.Error = appmessage.RPCErrorf("Transaction %s was not found", transactionID)
|
|
return errorMessage, nil
|
|
}
|
|
|
|
rpcTransaction := appmessage.DomainTransactionToRPCTransaction(transaction)
|
|
err = context.PopulateTransactionWithVerboseData(rpcTransaction, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return appmessage.NewGetMempoolEntryResponseMessage(transaction.Fee, rpcTransaction, isOrphan), nil
|
|
}
|