mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-21 22:06:47 +01:00
feat: add status types to dispatcher
This commit is contained in:
parent
397cd78ca9
commit
05e1396121
@ -3,6 +3,7 @@ package task
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/celo-org/celo-blockchain/common"
|
"github.com/celo-org/celo-blockchain/common"
|
||||||
"github.com/celo-org/celo-blockchain/core/types"
|
"github.com/celo-org/celo-blockchain/core/types"
|
||||||
@ -21,8 +22,9 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatchEventPayload struct {
|
dispatchEventPayload struct {
|
||||||
OtxId uint
|
OtxId uint
|
||||||
TxHash string
|
TxHash string
|
||||||
|
DispatchStatus status.Status
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,8 +56,16 @@ func TxDispatch(
|
|||||||
ctx,
|
ctx,
|
||||||
eth.SendTx(p.Tx).Returns(&txHash),
|
eth.SendTx(p.Tx).Returns(&txHash),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
// TODO: Coreect error status
|
switch err.Error() {
|
||||||
dispatchStatus.Status = status.FailGasPrice
|
case celo.ErrGasPriceLow:
|
||||||
|
dispatchStatus.Status = status.FailGasPrice
|
||||||
|
case celo.ErrInsufficientGas:
|
||||||
|
dispatchStatus.Status = status.FailInsufficientGas
|
||||||
|
case celo.ErrNonceLow:
|
||||||
|
dispatchStatus.Status = status.FailNonce
|
||||||
|
default:
|
||||||
|
dispatchStatus.Status = status.Unknown
|
||||||
|
}
|
||||||
|
|
||||||
_, err := pg.CreateDispatchStatus(ctx, dispatchStatus)
|
_, err := pg.CreateDispatchStatus(ctx, dispatchStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,7 +82,7 @@ func TxDispatch(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return fmt.Errorf("dispatch: failed %v: %w", err, asynq.SkipRetry)
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchStatus.Status = status.Successful
|
dispatchStatus.Status = status.Successful
|
||||||
|
Loading…
Reference in New Issue
Block a user