diff --git a/Transfer.go b/Transfer.go index c5e6e7e..8b3bd97 100644 --- a/Transfer.go +++ b/Transfer.go @@ -86,7 +86,7 @@ func SendPingTx(param SendPingTxParam) (string, string, PingResultError) { latestBlockhashResponse, err := param.Client.GetLatestBlockhashWithConfig( context.Background(), client.GetLatestBlockhashConfig{ - Commitment: rpc.CommitmentConfirmed, + Commitment: rpc.CommitmentFinalized, }, ) if err != nil { @@ -132,7 +132,7 @@ func SendPingTx(param SendPingTxParam) (string, string, PingResultError) { context.Background(), tx, client.SendTransactionConfig{ - SkipPreflight: true, + PreflightCommitment: rpc.CommitmentFinalized, }, ) if err != nil { @@ -231,7 +231,7 @@ func isBlockhashValid(c *client.Client, ctx context.Context, blockhash string) ( ctx, blockhash, client.IsBlockhashValidConfig{ - Commitment: rpc.CommitmentConfirmed, + Commitment: rpc.CommitmentFinalized, }, ) if err != nil { diff --git a/rpcPing.go b/rpcPing.go index d13d05f..c8eb360 100644 --- a/rpcPing.go +++ b/rpcPing.go @@ -69,6 +69,8 @@ func Ping(c *client.Client, pType PingType, acct types.Account, config ClusterCo timer.Add() confirmedCount++ } else { + startTime := time.Now() + endTime := startTime.Add(5 * time.Second) txhash, blockhash, pingErr := SendPingTx(SendPingTxParam{ Client: c, FeePayer: acct, @@ -76,6 +78,9 @@ func Ping(c *client.Client, pType PingType, acct types.Account, config ClusterCo ComputeUnitPrice: computeUnitPrice, ReceiverPubkey: config.Receiver, }) + if time.Now().After(endTime) { + resultErrs = append(resultErrs, "Send Ping took over 5 seconds") + } if pingErr.HasError() { timer.TimerStop() if !pingErr.IsInErrorList(PingTakeTimeErrExpectionList) { @@ -84,7 +89,12 @@ func Ping(c *client.Client, pType PingType, acct types.Account, config ClusterCo resultErrs = append(resultErrs, string(pingErr)) continue } + startTimeConfirmation := time.Now() + endTimeConfirmation := startTimeConfirmation.Add(10 * time.Second) waitErr := waitConfirmationOrBlockhashInvalid(c, txhash, blockhash) + if time.Now().After(endTimeConfirmation) { + resultErrs = append(resultErrs, "Confirmation took over 10 seconds") + } timer.TimerStop() if waitErr.HasError() { resultErrs = append(resultErrs, string(waitErr))