enhance pending transaction handling (#160)

This commit is contained in:
Francisco Gindre 2020-07-20 14:38:26 -03:00 committed by GitHub
parent 8ab608cce1
commit 74dfc38ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -137,11 +137,23 @@ public extension PendingTransactionEntity {
func isPending(currentHeight: Int = -1) -> Bool {
// not mined and not expired and successfully created
!isSubmitSuccess && minedHeight == -1 && (expiryHeight == -1 || expiryHeight > currentHeight) && raw != nil
isSubmitSuccess && !isConfirmed(currentHeight: currentHeight) && (expiryHeight == -1 || expiryHeight > currentHeight) && raw != nil
}
var isSubmitSuccess: Bool {
submitAttempts > 0 && (errorCode != nil && (errorCode ?? -1) >= 0) && errorMessage == nil
submitAttempts > 0 && (errorCode == nil || (errorCode ?? 0) >= 0) && errorMessage == nil
}
func isConfirmed(currentHeight: Int = -1 ) -> Bool {
guard minedHeight > 0 else {
return false
}
guard currentHeight > 0 else {
return false
}
return abs(currentHeight - minedHeight) >= ZcashSDK.DEFAULT_STALE_TOLERANCE
}
}