-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5abcf03
commit 442e71d
Showing
2 changed files
with
9 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"time" | ||
) | ||
|
||
func waitForTxConfirmation(cmdPath, node, txHash string, timeout time.Duration) error { | ||
func waitForTxConfirmation(cmdPath, node, txHash string, timeout time.Duration) { | ||
start := time.Now() | ||
for { | ||
if time.Since(start) > timeout { | ||
return fmt.Errorf("timeout reached while waiting for tx confirmation") | ||
log.Fatalf(ColorRed + "timeout reached while waiting for tx confirmation") | ||
} | ||
success, err := checkTxStatus(cmdPath, node, txHash) | ||
if err != nil { | ||
log.Printf("error checking tx status: %v", err) | ||
log.Printf(ColorRed+"error checking tx status, retrying in 5 seconds: %v", err) | ||
time.Sleep(5 * time.Second) | ||
continue | ||
} | ||
if success { | ||
return nil | ||
break | ||
} | ||
time.Sleep(10 * time.Second) | ||
log.Printf(ColorYellow+"waiting for tx confirmation %s", txHash) | ||
time.Sleep(5 * time.Second) | ||
} | ||
log.Printf(ColorGreen+"tx %s confirmed", txHash) | ||
} |