Skip to content

Commit c504ae0

Browse files
committed
Add unused linter, delete unused code
1 parent 875e474 commit c504ae0

42 files changed

Lines changed: 9 additions & 1365 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: "2"
22
linters:
33
default: none
44
enable:
5+
- unused
56
- staticcheck
67
settings:
78
staticcheck:

bindings/dao/protocol/dao.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

bindings/minipool/minipool-constructor.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package minipool
33
import (
44
"fmt"
55
"strings"
6-
"sync"
76

87
"github.com/ethereum/go-ethereum/accounts/abi"
98
"github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -77,12 +76,3 @@ func createMinipoolContractFromAbi(rp *rocketpool.RocketPool, address common.Add
7776
Client: rp.Client,
7877
}, nil
7978
}
80-
81-
// Get a minipool contract
82-
var rocketMinipoolLock sync.Mutex
83-
84-
func getMinipoolContract(rp *rocketpool.RocketPool, minipoolAddress common.Address, opts *bind.CallOpts) (*rocketpool.Contract, error) {
85-
rocketMinipoolLock.Lock()
86-
defer rocketMinipoolLock.Unlock()
87-
return rp.MakeContract("rocketMinipool", minipoolAddress, opts)
88-
}

bindings/rocketpool/contract.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,6 @@ func (c *Contract) estimateGasLimit(opts *bind.TransactOpts, input []byte) (uint
155155

156156
}
157157

158-
// Wait for a transaction to be mined and get a tx receipt
159-
func (c *Contract) getTransactionReceipt(tx *types.Transaction) (*types.Receipt, error) {
160-
161-
// Wait for transaction to be mined
162-
txReceipt, err := bind.WaitMined(context.Background(), c.Client, tx)
163-
if err != nil {
164-
return nil, err
165-
}
166-
167-
// Check transaction status
168-
if txReceipt.Status == 0 {
169-
return txReceipt, errors.New("Transaction failed with status 0")
170-
}
171-
172-
// Return
173-
return txReceipt, nil
174-
175-
}
176-
177158
// Get contract events from a transaction
178159
// eventPrototype must be an event struct type
179160
// Returns a slice of untyped values; assert returned events to event struct type

rocketpool-cli/node/sync.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ package node
33
import (
44
"fmt"
55
"strings"
6-
"time"
76

87
"github.com/rocket-pool/smartnode/shared/services/rocketpool"
98
"github.com/rocket-pool/smartnode/shared/types/api"
109
cliutils "github.com/rocket-pool/smartnode/shared/utils/cli"
1110
"github.com/rocket-pool/smartnode/shared/utils/cli/color"
1211
)
1312

14-
// Settings
15-
var ethClientRecentBlockThreshold, _ = time.ParseDuration("5m")
16-
1713
func printClientStatus(status *api.ClientStatus, name string) {
1814

1915
if status.Error != "" {

rocketpool-cli/node/utils.go

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,8 @@ import (
1313
"unicode"
1414

1515
"github.com/goccy/go-json"
16-
"github.com/mitchellh/go-homedir"
17-
"gopkg.in/yaml.v2"
1816

19-
"github.com/rocket-pool/smartnode/bindings/types"
20-
"github.com/rocket-pool/smartnode/shared/services/config"
21-
"github.com/rocket-pool/smartnode/shared/services/rocketpool"
22-
"github.com/rocket-pool/smartnode/shared/types/api"
2317
"github.com/rocket-pool/smartnode/shared/utils/cli/prompt"
24-
hexutils "github.com/rocket-pool/smartnode/shared/utils/hex"
2518
)
2619

2720
// IPInfo API
@@ -255,75 +248,3 @@ func promptTimezone() string {
255248
fmt.Printf("Using timezone %s.\n", timezone)
256249
return timezone
257250
}
258-
259-
// Prompt for the password to a solo validator key as part of migration
260-
func promptForSoloKeyPassword(rp *rocketpool.Client, cfg *config.RocketPoolConfig, pubkey types.ValidatorPubkey) (string, error) {
261-
262-
// Check for the custom key directory
263-
datapath, err := homedir.Expand(cfg.Smartnode.DataPath.Value.(string))
264-
if err != nil {
265-
return "", fmt.Errorf("error expanding data directory: %w", err)
266-
}
267-
customKeyDir := filepath.Join(datapath, "custom-keys")
268-
info, err := os.Stat(customKeyDir)
269-
if os.IsNotExist(err) || !info.IsDir() {
270-
return "", nil
271-
}
272-
273-
// Get the custom keystore files
274-
files, err := os.ReadDir(customKeyDir)
275-
if err != nil {
276-
return "", fmt.Errorf("error enumerating custom keystores: %w", err)
277-
}
278-
if len(files) == 0 {
279-
return "", nil
280-
}
281-
282-
// Get the pubkeys for the custom keystores
283-
pubkeyPasswords := map[string]string{}
284-
for _, file := range files {
285-
// Read the file
286-
bytes, err := os.ReadFile(filepath.Join(customKeyDir, file.Name()))
287-
if err != nil {
288-
return "", fmt.Errorf("error reading custom keystore %s: %w", file.Name(), err)
289-
}
290-
291-
// Deserialize it
292-
keystore := api.ValidatorKeystore{}
293-
err = json.Unmarshal(bytes, &keystore)
294-
if err != nil {
295-
return "", fmt.Errorf("error deserializing custom keystore %s: %w", file.Name(), err)
296-
}
297-
298-
if keystore.Pubkey == pubkey {
299-
// Found it, prompt for the password
300-
password := prompt.PromptPassword(
301-
fmt.Sprintf("Please enter the password that the keystore for %s was encrypted with:", pubkey.Hex()), "^.*$", "",
302-
)
303-
304-
formattedPubkey := strings.ToUpper(hexutils.RemovePrefix(pubkey.Hex()))
305-
pubkeyPasswords[formattedPubkey] = password
306-
307-
fmt.Println()
308-
break
309-
}
310-
}
311-
312-
if len(pubkeyPasswords) == 0 {
313-
return "", fmt.Errorf("couldn't find the keystore for validator %s in the custom-keys directory; if you want to import this key into the Smart Node stack, you will need to put its keystore file into custom-keys first", pubkey.String())
314-
}
315-
316-
// Store it in the file
317-
fileBytes, err := yaml.Marshal(pubkeyPasswords)
318-
if err != nil {
319-
return "", fmt.Errorf("error serializing keystore passwords file: %w", err)
320-
}
321-
passwordFile := filepath.Join(datapath, "custom-key-passwords")
322-
err = os.WriteFile(passwordFile, fileBytes, 0600)
323-
if err != nil {
324-
return "", fmt.Errorf("error writing keystore passwords file: %w", err)
325-
}
326-
327-
return passwordFile, nil
328-
329-
}

rocketpool-cli/pdao/propose-settings.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package pdao
33
import (
44
"fmt"
55
"math/big"
6-
"strings"
76
"time"
87

9-
"github.com/ethereum/go-ethereum/common"
108
"github.com/rocket-pool/smartnode/bindings/settings/protocol"
119
"github.com/rocket-pool/smartnode/bindings/utils/eth"
1210

@@ -318,15 +316,6 @@ func proposeSettingSecurityProposalActionTime(value time.Duration, yes bool) err
318316
return proposeSetting(protocol.SecuritySettingsContractName, protocol.SecurityProposalActionTimeSettingPath, trueValue, yes)
319317
}
320318

321-
func proposeSettingNetworkAllowListedControllers(value []common.Address, yes bool) error {
322-
strs := make([]string, len(value))
323-
for i, addr := range value {
324-
strs[i] = addr.Hex()
325-
}
326-
trueValue := strings.Join(strs, "")
327-
return proposeSetting(protocol.NetworkSettingsContractName, protocol.NetworkAllowListedControllersPath, trueValue, yes)
328-
}
329-
330319
func proposeSettingMegapoolTimeBeforeDissolve(value time.Duration, yes bool) error {
331320
trueValue := fmt.Sprint(uint64(value.Seconds()))
332321
return proposeSetting(protocol.MegapoolSettingsContractName, protocol.MegapoolTimeBeforeDissolveSettingsPath, trueValue, yes)

rocketpool-cli/service/config/addons.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ const addonPageID string = "addons"
1111

1212
// The addons page
1313
type AddonsPage struct {
14-
home *settingsHome
15-
page *page
16-
layout *standardLayout
17-
masterConfig *config.RocketPoolConfig
18-
gwwPage *AddonGwwPage
19-
gwwButton *parameterizedFormItem
20-
rescueNodePage *AddonRescueNodePage
21-
rescueNodeButton *parameterizedFormItem
22-
categoryList *tview.List
23-
addonSubpages []settingsPage
24-
content tview.Primitive
14+
home *settingsHome
15+
page *page
16+
layout *standardLayout
17+
masterConfig *config.RocketPoolConfig
18+
gwwPage *AddonGwwPage
19+
rescueNodePage *AddonRescueNodePage
20+
categoryList *tview.List
21+
addonSubpages []settingsPage
2522
}
2623

2724
// Create a new addons page

rocketpool-cli/service/config/config-form.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ type parameterizedFormItem struct {
1616
item tview.FormItem
1717
}
1818

19-
func registerEnableCheckbox(param *cfgtypes.Parameter, checkbox *tview.Checkbox, form *Form, items []*parameterizedFormItem) {
20-
checkbox.SetChangedFunc(func(checked bool) {
21-
param.Value = checked
22-
23-
if !checked {
24-
form.Clear(true)
25-
form.AddFormItem(checkbox)
26-
} else {
27-
for _, item := range items {
28-
form.AddFormItem(item.item)
29-
}
30-
}
31-
})
32-
}
33-
3419
// Create a list of form items based on a set of parameters
3520
func createParameterizedFormItems(params []*cfgtypes.Parameter, descriptionBox *tview.TextView) []*parameterizedFormItem {
3621
formItems := []*parameterizedFormItem{}

rocketpool-cli/service/config/pseudomodal.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ type Pseudomodal struct {
3636

3737
// The currently selected form (for vertical layouts)
3838
selected int
39-
40-
// A fixed width for the description box (0 for auto)
41-
descriptionWidth int
42-
43-
// The collection of descriptions for each button, to be displayed in the description box
44-
buttonDescriptions []string
4539
}
4640

4741
// NewPseudomodal returns a new modal message window.

0 commit comments

Comments
 (0)