mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-20 13:56:45 +00:00
24 lines
880 B
Go
24 lines
880 B
Go
package rpcclient
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
)
|
|
|
|
// 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, allowOrphan bool) (*appmessage.SubmitTransactionResponseMessage, error) {
|
|
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewSubmitTransactionRequestMessage(transaction, allowOrphan))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
response, err := c.route(appmessage.CmdSubmitTransactionResponseMessage).DequeueWithTimeout(c.timeout)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
submitTransactionResponse := response.(*appmessage.SubmitTransactionResponseMessage)
|
|
if submitTransactionResponse.Error != nil {
|
|
return nil, c.convertRPCError(submitTransactionResponse.Error)
|
|
}
|
|
|
|
return submitTransactionResponse, nil
|
|
}
|