Commit b0eebab8 authored by luxq's avatar luxq

add log

parent 611f7399
Pipeline #916 failed with stages
......@@ -56,18 +56,19 @@ func SendAndWait(client *ethclient.Client, ctx context.Context, pk *ecdsa.Privat
if err != nil {
log.Fatalf("failed to sign tx: %v", err)
}
t1 := time.Now()
err = client.SendTransaction(ctx, signedTx)
if err != nil {
log.Fatalln(fmt.Errorf("failed to send tx: %v", err))
}
t1 := time.Now()
t2 := time.Now()
tm := time.NewTicker(100 * time.Millisecond)
for {
select {
case <-tm.C:
receipt, _ := client.TransactionReceipt(ctx, signedTx.Hash())
if receipt != nil {
fmt.Println("tx mined in ", time.Since(t1).String())
fmt.Printf("tx send cost %v, mined cost %v, total cost %v\n", t2.Sub(t1), time.Since(t2), time.Since(t1))
return
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment