Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions btp/btp.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ func (b *BTP) updateResult(rm *chain.RelayMessage, segment *chain.Segment) (err
segment.GetResultParam = nil
case chain.BMCRevertUnauthorized:
segment.GetResultParam = nil
case chain.ICONSkipTransaction:
segment.GetResultParam = nil
default:
b.log.Panicf("fail to GetResult GetResultParam:%v ErrorCoder:%+v", segment.GetResultParam, ec)
}
Expand Down
36 changes: 31 additions & 5 deletions chain/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ var (
)

const (
CodeBTP errors.Code = 0
CodeBMC errors.Code = 10
CodeBMV errors.Code = 25
CodeBSH errors.Code = 40
CodeReserved errors.Code = 55
CodeBTP errors.Code = 0
CodeBMC errors.Code = 10
CodeBMV errors.Code = 25
CodeBSH errors.Code = 40
CodeReserved errors.Code = 55
CodeRetryable errors.Code = 1000
)

const (
Expand Down Expand Up @@ -100,6 +101,31 @@ var (
}
)

const (
GenericRetryable = CodeRetryable + iota
ICONSkipTransaction
)

var (
RetrybleCodeNames = map[errors.Code]string{
GenericRetryable: "GenericRetryable",
ICONSkipTransaction: "ICONSkipTransaction",
}
)

func NewRetryable(code int) error {
c := errors.Code(code)
if c >= CodeRetryable {
var msg string
var ok bool
if msg, ok = RetrybleCodeNames[c]; !ok {
msg = fmt.Sprintf("Retryable[%d]", c)
}
return errors.NewBase(c, msg)
}
return nil
}

func NewRevertError(code int) error {
c := errors.Code(code)
if c >= CodeBTP {
Expand Down
4 changes: 2 additions & 2 deletions chain/icon/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ func (s *sender) sendFragmentations(tps []*TransactionParam, idxs []int) (chain.
if err != nil {
s.l.Panicf("sendFragmentations: fails result %+v error%+v", grp, err)
}
// TODO use (finalizelatency * blockinterval / appropriateratio) * time.Second
time.Sleep(time.Duration(s.FinalizeLatency()) * time.Second)
}

s.l.Tracef("sendFragmentations: end")
Expand Down Expand Up @@ -602,6 +600,8 @@ func mapErrorWithTransactionResult(txr *TransactionResult, err error) error {
if fc < ResultStatusFailureCodeRevert || fc > ResultStatusFailureCodeEnd {
err = fmt.Errorf("failure with code:%s, message:%s",
txr.Failure.CodeValue, txr.Failure.MessageValue)
} else if fc == ResultStatusSkipTransaction {
err = chain.NewRetryable(int(chain.ICONSkipTransaction))
} else {
err = chain.NewRevertError(int(fc - ResultStatusFailureCodeRevert))
}
Expand Down
1 change: 1 addition & 0 deletions chain/icon/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (

const (
ResultStatusSuccess = "0x1"
ResultStatusSkipTransaction = 14
ResultStatusFailureCodeRevert = 32
ResultStatusFailureCodeEnd = 99
)
Expand Down