mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-21 06:16:45 +00:00

* fix mempool accessing, rewrite get_mempool_entries_by_addresses * fix counter, add verbose * fmt * addresses as string * Define error in case utxoEntry is missing. * fix error variable to string * stop tests from failing (see in code comment) * access both pools in the same state via parameters * get rid of todo message * fmt - very important! * perf: scriptpublickey in mempool, no txscript. * address reveiw * fmt fix * mixed up isorphan bool, pass tests now * do map preallocation in mempoolbyaddresses * no proallocation for orphanpool sending. Co-authored-by: Ori Newman <orinewman1@gmail.com>
48 lines
1.7 KiB
Go
48 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/infrastructure/network/netadapter/router"
|
|
)
|
|
|
|
// HandleGetMempoolEntries handles the respectively named RPC command
|
|
func HandleGetMempoolEntries(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
|
|
getMempoolEntriesRequest := request.(*appmessage.GetMempoolEntriesRequestMessage)
|
|
|
|
entries := make([]*appmessage.MempoolEntry, 0)
|
|
|
|
transactionPoolTransactions, orphanPoolTransactions := context.Domain.MiningManager().AllTransactions(!getMempoolEntriesRequest.FilterTransactionPool, getMempoolEntriesRequest.IncludeOrphanPool)
|
|
|
|
if !getMempoolEntriesRequest.FilterTransactionPool {
|
|
for _, transaction := range transactionPoolTransactions {
|
|
rpcTransaction := appmessage.DomainTransactionToRPCTransaction(transaction)
|
|
err := context.PopulateTransactionWithVerboseData(rpcTransaction, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
entries = append(entries, &appmessage.MempoolEntry{
|
|
Fee: transaction.Fee,
|
|
Transaction: rpcTransaction,
|
|
IsOrphan: false,
|
|
})
|
|
}
|
|
}
|
|
if getMempoolEntriesRequest.IncludeOrphanPool {
|
|
for _, transaction := range orphanPoolTransactions {
|
|
rpcTransaction := appmessage.DomainTransactionToRPCTransaction(transaction)
|
|
err := context.PopulateTransactionWithVerboseData(rpcTransaction, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
entries = append(entries, &appmessage.MempoolEntry{
|
|
Fee: transaction.Fee,
|
|
Transaction: rpcTransaction,
|
|
IsOrphan: true,
|
|
})
|
|
}
|
|
}
|
|
|
|
return appmessage.NewGetMempoolEntriesResponseMessage(entries), nil
|
|
}
|