Skip to content

Commit

Permalink
Remove TxError
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Nov 13, 2024
1 parent 4959f2d commit 91c64b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
5 changes: 1 addition & 4 deletions pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ func newChain(id string, cfg *config.TOMLConfig, ks loop.Keystore, lggr logger.L
if result == nil {
return solanago.Signature{}, errors.New("tx sender returned nil result")
}
if result.Error() != nil {
return solanago.Signature{}, result.Error()
}
return result.Signature(), result.TxError()
return result.Signature(), result.Error()
}

tc = internal.NewLoader[client.ReaderWriter](func() (client.ReaderWriter, error) { return ch.multiNode.SelectRPC() })
Expand Down
5 changes: 2 additions & 3 deletions pkg/solana/client/multinode/transaction_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var (

type SendTxResult interface {
Code() SendTxReturnCode
TxError() error
Error() error
}

Expand Down Expand Up @@ -162,9 +161,9 @@ func (txSender *TransactionSender[TX, RESULT, CHAIN_ID, RPC]) SendTransaction(ct

func (txSender *TransactionSender[TX, RESULT, CHAIN_ID, RPC]) broadcastTxAsync(ctx context.Context, rpc RPC, tx TX) RESULT {
result := rpc.SendTransaction(ctx, tx)
txSender.lggr.Debugw("Node sent transaction", "tx", tx, "err", result.TxError())
txSender.lggr.Debugw("Node sent transaction", "tx", tx, "err", result.Error())
if !slices.Contains(sendTxSuccessfulCodes, result.Code()) && ctx.Err() == nil {
txSender.lggr.Warnw("RPC returned error", "tx", tx, "err", result.TxError())
txSender.lggr.Warnw("RPC returned error", "tx", tx, "err", result.Error())
}
return result
}
Expand Down
18 changes: 6 additions & 12 deletions pkg/solana/client/multinode_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,16 @@ func (m *MultiNodeClient) GetInterceptedChainInfo() (latest, highestUserObservat
}

type SendTxResult struct {
err error
txErr error
code mn.SendTxReturnCode
sig solana.Signature
err error
code mn.SendTxReturnCode
sig solana.Signature
}

var _ mn.SendTxResult = (*SendTxResult)(nil)

func NewSendTxResult(err error) *SendTxResult {
result := &SendTxResult{
err: err,
txErr: err,
err: err,
}
result.code = ClassifySendError(nil, err)
return result
Expand All @@ -342,10 +340,6 @@ func (r *SendTxResult) Error() error {
return r.err
}

func (r *SendTxResult) TxError() error {
return r.txErr
}

func (r *SendTxResult) Code() mn.SendTxReturnCode {
return r.code
}
Expand All @@ -356,7 +350,7 @@ func (r *SendTxResult) Signature() solana.Signature {

func (m *MultiNodeClient) SendTransaction(ctx context.Context, tx *solana.Transaction) *SendTxResult {
var sendTxResult = &SendTxResult{}
sendTxResult.sig, sendTxResult.txErr = m.SendTx(ctx, tx)
sendTxResult.code = ClassifySendError(tx, sendTxResult.txErr)
sendTxResult.sig, sendTxResult.err = m.SendTx(ctx, tx)
sendTxResult.code = ClassifySendError(tx, sendTxResult.err)
return sendTxResult
}

0 comments on commit 91c64b3

Please sign in to comment.