Skip to content

Commit ec056d2

Browse files
jannikluhnulope
authored andcommitted
Remove unused helper functions
1 parent 0dcb762 commit ec056d2

File tree

1 file changed

+0
-78
lines changed

1 file changed

+0
-78
lines changed

rolling-shutter/medley/medley.go

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
package medley
33

44
import (
5-
"bytes"
65
"context"
7-
"encoding/gob"
86
"errors"
9-
"fmt"
107
"math"
118
"os"
129
"strings"
1310
"time"
1411

15-
"github.com/ethereum/go-ethereum"
1612
"github.com/ethereum/go-ethereum/common"
17-
"github.com/ethereum/go-ethereum/core/types"
18-
"github.com/ethereum/go-ethereum/ethclient"
1913
pkgErrors "github.com/pkg/errors"
2014
"github.com/spf13/cobra"
2115
"github.com/spf13/pflag"
@@ -51,49 +45,6 @@ func Sleep(ctx context.Context, d time.Duration) {
5145
}
5246
}
5347

54-
// WaitMined waits for a transaction to be mined and returns its receipt. It's a replacement for
55-
// bind.WaitMined which doesn't seem to work with Ganache in some cases.
56-
func WaitMined(ctx context.Context, client *ethclient.Client, txHash common.Hash) (*types.Receipt, error) {
57-
for {
58-
receipt, err := client.TransactionReceipt(ctx, txHash)
59-
if err == ethereum.NotFound {
60-
Sleep(ctx, receiptPollInterval)
61-
continue
62-
}
63-
if err != nil {
64-
return nil, err
65-
}
66-
return receipt, nil
67-
}
68-
}
69-
70-
func WaitMinedMany(ctx context.Context, client *ethclient.Client, txHashes []common.Hash) ([]*types.Receipt, error) {
71-
defer fmt.Print("\n")
72-
var res []*types.Receipt
73-
74-
failedTxs := []int{}
75-
for i, txHash := range txHashes {
76-
receipt, err := WaitMined(ctx, client, txHash)
77-
if err != nil {
78-
return res, err
79-
}
80-
res = append(res, receipt)
81-
if receipt.Status != 1 {
82-
fmt.Print("X")
83-
failedTxs = append(failedTxs, i)
84-
} else {
85-
fmt.Print(".")
86-
}
87-
}
88-
89-
if len(failedTxs) > 0 {
90-
firstFailed := failedTxs[0]
91-
return res, pkgErrors.Errorf("some txs have failed, the first being %s", txHashes[firstFailed])
92-
}
93-
94-
return res, nil
95-
}
96-
9748
// EnsureUniqueAddresses makes sure the slice of addresses doesn't contain duplicate addresses.
9849
func EnsureUniqueAddresses(addrs []common.Address) error {
9950
seen := make(map[common.Address]struct{})
@@ -106,35 +57,6 @@ func EnsureUniqueAddresses(addrs []common.Address) error {
10657
return nil
10758
}
10859

109-
// DedupAddresses returns a new slice containing only unique addresses.
110-
func DedupAddresses(addrs []common.Address) []common.Address {
111-
var res []common.Address
112-
seen := make(map[common.Address]struct{})
113-
114-
for _, a := range addrs {
115-
if _, ok := seen[a]; ok {
116-
continue
117-
}
118-
seen[a] = struct{}{}
119-
res = append(res, a)
120-
}
121-
122-
return res
123-
}
124-
125-
// CloneWithGob clones the given object by serializing/deserializing with gob.
126-
func CloneWithGob(src, dst interface{}) {
127-
buff := bytes.Buffer{}
128-
err := gob.NewEncoder(&buff).Encode(src)
129-
if err != nil {
130-
panic(err)
131-
}
132-
err = gob.NewDecoder(&buff).Decode(dst)
133-
if err != nil {
134-
panic(err)
135-
}
136-
}
137-
13860
func normName(s string) string {
13961
return strings.ToUpper(strings.ReplaceAll(s, "-", "_"))
14062
}

0 commit comments

Comments
 (0)