Skip to content

Commit

Permalink
Add allowOrphans to rpcclient.SubmitTransaction (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
svarogg authored Jun 24, 2021
1 parent c13a4d9 commit 798c5fa
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/appmessage/rpc_submit_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ func (msg *SubmitTransactionRequestMessage) Command() MessageCommand {
}

// NewSubmitTransactionRequestMessage returns a instance of the message
func NewSubmitTransactionRequestMessage(transaction *RPCTransaction) *SubmitTransactionRequestMessage {
func NewSubmitTransactionRequestMessage(transaction *RPCTransaction, allowOrphan bool) *SubmitTransactionRequestMessage {
return &SubmitTransactionRequestMessage{
Transaction: transaction,
AllowOrphan: allowOrphan,
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/kaspawallet/daemon/server/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"

"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
"github.com/kaspanet/kaspad/cmd/kaspawallet/libkaspawallet"
Expand All @@ -25,7 +26,7 @@ func (s *server) Broadcast(_ context.Context, request *pb.BroadcastRequest) (*pb
}

func sendTransaction(client *rpcclient.RPCClient, tx *externalapi.DomainTransaction) (string, error) {
submitTransactionResponse, err := client.SubmitTransaction(appmessage.DomainTransactionToRPCTransaction(tx))
submitTransactionResponse, err := client.SubmitTransaction(appmessage.DomainTransactionToRPCTransaction(tx), false)
if err != nil {
return "", errors.Wrapf(err, "error submitting transaction")
}
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/network/rpcclient/rpc_send_raw_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
)

// SubmitTransaction sends an RPC request respective to the function's name and returns the RPC server's response
func (c *RPCClient) SubmitTransaction(transaction *appmessage.RPCTransaction) (*appmessage.SubmitTransactionResponseMessage, error) {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewSubmitTransactionRequestMessage(transaction))
func (c *RPCClient) SubmitTransaction(transaction *appmessage.RPCTransaction, allowOrphan bool) (*appmessage.SubmitTransactionResponseMessage, error) {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewSubmitTransactionRequestMessage(transaction, allowOrphan))
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions stability-tests/mempool-limits/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package mempoollimits

import (
"encoding/hex"
"strings"
"testing"

"github.com/kaspanet/go-secp256k1"
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
Expand All @@ -15,8 +18,6 @@ import (
"github.com/kaspanet/kaspad/infrastructure/network/rpcclient"
"github.com/kaspanet/kaspad/stability-tests/common/mine"
"github.com/kaspanet/kaspad/util"
"strings"
"testing"
)

const (
Expand Down Expand Up @@ -85,7 +86,7 @@ func submitAnAmountOfTransactionsToTheMempool(t *testing.T, rpcClient *rpcclient

for i, transaction := range transactions {
rpcTransaction := appmessage.DomainTransactionToRPCTransaction(transaction)
_, err := rpcClient.SubmitTransaction(rpcTransaction)
_, err := rpcClient.SubmitTransaction(rpcTransaction, false)
if err != nil {
if ignoreOrphanRejects && strings.Contains(err.Error(), "orphan") {
continue
Expand Down
2 changes: 1 addition & 1 deletion testing/integration/tx_relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestTxRelay(t *testing.T) {
msgTx := generateTx(t, secondBlock.Transactions[transactionhelper.CoinbaseTransactionIndex], payer, payee)
domainTransaction := appmessage.MsgTxToDomainTransaction(msgTx)
rpcTransaction := appmessage.DomainTransactionToRPCTransaction(domainTransaction)
response, err := payer.rpcClient.SubmitTransaction(rpcTransaction)
response, err := payer.rpcClient.SubmitTransaction(rpcTransaction, false)
if err != nil {
t.Fatalf("Error submitting transaction: %+v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion testing/integration/utxo_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestUTXOIndex(t *testing.T) {
const transactionAmountToSpend = 5
for i := 0; i < transactionAmountToSpend; i++ {
rpcTransaction := buildTransactionForUTXOIndexTest(t, notificationEntries[i])
_, err = kaspad.rpcClient.SubmitTransaction(rpcTransaction)
_, err = kaspad.rpcClient.SubmitTransaction(rpcTransaction, false)
if err != nil {
t.Fatalf("Error submitting transaction: %s", err)
}
Expand Down

0 comments on commit 798c5fa

Please sign in to comment.