Skip to content

Commit

Permalink
Reset Lookup Time
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsmith-2019 committed Oct 29, 2024
1 parent c4253b1 commit 13063cc
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions node/pkg/wormconn/send_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,20 @@ func (c *ClientConn) SignAndBroadcastTx(ctx context.Context, msg sdktypes.Msg) (

// waitForBlockInclusion waits for the tx to be included in a block, or times out after a given duration.
func waitForBlockInclusion(ctx context.Context, client sdktx.ServiceClient, txHash string, waitTimeout time.Duration) (*sdktx.GetTxResponse, error) {

now := time.Now()

exitAfter := time.After(waitTimeout)
for {
select {
// check if wait timeout is exceeded
case <-exitAfter:
fmt.Println("JOEL - TIMED OUT ", txHash)
return nil, fmt.Errorf("timed out after: %d; wait for tx %s to be included in a block", waitTimeout, txHash)
// check if in block every second
case <-time.After(3000 * time.Millisecond):
case <-time.After(100 * time.Millisecond):
res, err := client.GetTx(ctx, &sdktx.GetTxRequest{Hash: txHash})
if err == nil {
took := time.Since(now)
fmt.Println("JOEL - FOUND TX IN BLOCK", txHash, " after ", took.Milliseconds(), "ms")
return res, nil
} else {
fmt.Println("JOEL - NO TX YET IN BLOCK ", txHash)
}
// check if context is done
case <-ctx.Done():
fmt.Println("JOEL - CONTEXT DONE ", txHash, ctx.Err())
return nil, ctx.Err()
}
}
Expand Down

0 comments on commit 13063cc

Please sign in to comment.