Skip to content

Commit

Permalink
Add debug and use finalized commit level
Browse files Browse the repository at this point in the history
  • Loading branch information
bw-solana committed Apr 29, 2024
1 parent 8991bc7 commit 6ac7643
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -132,7 +132,7 @@ func SendPingTx(param SendPingTxParam) (string, string, PingResultError) {
context.Background(),
tx,
client.SendTransactionConfig{
SkipPreflight: true,
PreflightCommitment: rpc.CommitmentFinalized,
},
)
if err != nil {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions rpcPing.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ 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,
RequestComputeUnits: config.RequestUnits,
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) {
Expand All @@ -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))
Expand Down

0 comments on commit 6ac7643

Please sign in to comment.