Skip to content

Commit

Permalink
refactor: export tx status consts (#1451)
Browse files Browse the repository at this point in the history
## Description

Make TxStatus consts public
  • Loading branch information
ninabarbakadze authored Aug 15, 2024
1 parent a6658ff commit 353761f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions rpc/core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

const (
txStatusUnknown string = "UNKNOWN"
txStatusPending string = "PENDING"
txStatusEvicted string = "EVICTED"
txStatusCommitted string = "COMMITTED"
TxStatusUnknown string = "UNKNOWN"
TxStatusPending string = "PENDING"
TxStatusEvicted string = "EVICTED"
TxStatusCommitted string = "COMMITTED"
)

// Tx allows you to query the transaction results. `nil` could mean the
Expand Down Expand Up @@ -229,7 +229,7 @@ func TxStatus(ctx *rpctypes.Context, hash []byte) (*ctypes.ResultTxStatus, error
// Check if the tx has been committed
txInfo := env.BlockStore.LoadTxInfo(hash)
if txInfo != nil {
return &ctypes.ResultTxStatus{Height: txInfo.Height, Index: txInfo.Index, ExecutionCode: txInfo.Code, Status: txStatusCommitted}, nil
return &ctypes.ResultTxStatus{Height: txInfo.Height, Index: txInfo.Index, ExecutionCode: txInfo.Code, Status: TxStatusCommitted}, nil
}

// Get the tx key from the hash
Expand All @@ -241,17 +241,17 @@ func TxStatus(ctx *rpctypes.Context, hash []byte) (*ctypes.ResultTxStatus, error
// Check if the tx is in the mempool
txInMempool, ok := env.Mempool.GetTxByKey(txKey)
if txInMempool != nil && ok {
return &ctypes.ResultTxStatus{Status: txStatusPending}, nil
return &ctypes.ResultTxStatus{Status: TxStatusPending}, nil
}

// Check if the tx is evicted
isEvicted := env.Mempool.WasRecentlyEvicted(txKey)
if isEvicted {
return &ctypes.ResultTxStatus{Status: txStatusEvicted}, nil
return &ctypes.ResultTxStatus{Status: TxStatusEvicted}, nil
}

// If the tx is not in the mempool, evicted, or committed, return unknown
return &ctypes.ResultTxStatus{Status: txStatusUnknown}, nil
return &ctypes.ResultTxStatus{Status: TxStatusUnknown}, nil
}

// ProveSharesV2 creates a proof for a set of shares to the data root.
Expand Down

0 comments on commit 353761f

Please sign in to comment.