Skip to content

Commit

Permalink
Remove redundant type StakeOptions.
Browse files Browse the repository at this point in the history
It only wrapped one boolean value so doesn't serve any purpose when the
boolean can be used directly.
  • Loading branch information
jholdstock committed Sep 10, 2024
1 parent f597088 commit 5eff60a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
6 changes: 2 additions & 4 deletions dcrwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,8 @@ func run(ctx context.Context) error {
// --noinitialload is not set, this function is responsible for loading the
// wallet. Otherwise, loading is deferred so it can be performed over RPC.
dbDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
stakeOptions := &ldr.StakeOptions{
VotingEnabled: cfg.EnableVoting,
}
loader := ldr.NewLoader(activeNet.Params, dbDir, stakeOptions,

loader := ldr.NewLoader(activeNet.Params, dbDir, cfg.EnableVoting,
cfg.GapLimit, cfg.WatchLast, cfg.AllowHighFees, cfg.RelayFee.Amount,
cfg.AccountGapLimit, cfg.DisableCoinTypeUpgrades, !cfg.Mixing,
cfg.ManualTickets, cfg.MixSplitLimit)
Expand Down
20 changes: 6 additions & 14 deletions internal/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Loader struct {
wallet *wallet.Wallet
db wallet.DB

stakeOptions *StakeOptions
votingEnabled bool
gapLimit uint32
watchLast uint32
accountGapLimit int
Expand All @@ -51,20 +51,15 @@ type Loader struct {
mu sync.Mutex
}

// StakeOptions contains the various options necessary for stake mining.
type StakeOptions struct {
VotingEnabled bool
}

// NewLoader constructs a Loader.
func NewLoader(chainParams *chaincfg.Params, dbDirPath string, stakeOptions *StakeOptions, gapLimit uint32,
func NewLoader(chainParams *chaincfg.Params, dbDirPath string, votingEnabled bool, gapLimit uint32,
watchLast uint32, allowHighFees bool, relayFee dcrutil.Amount, accountGapLimit int,
disableCoinTypeUpgrades bool, disableMixing bool, manualTickets bool, mixSplitLimit int) *Loader {

return &Loader{
chainParams: chainParams,
dbDirPath: dbDirPath,
stakeOptions: stakeOptions,
votingEnabled: votingEnabled,
gapLimit: gapLimit,
watchLast: watchLast,
accountGapLimit: accountGapLimit,
Expand Down Expand Up @@ -167,11 +162,10 @@ func (l *Loader) CreateWatchingOnlyWallet(ctx context.Context, extendedPubKey st
}

// Open the watch-only wallet.
so := l.stakeOptions
cfg := &wallet.Config{
DB: db,
PubPassphrase: pubPass,
VotingEnabled: so.VotingEnabled,
VotingEnabled: l.votingEnabled,
GapLimit: l.gapLimit,
WatchLast: l.watchLast,
AccountGapLimit: l.accountGapLimit,
Expand Down Expand Up @@ -256,11 +250,10 @@ func (l *Loader) CreateNewWallet(ctx context.Context, pubPassphrase, privPassphr
}

// Open the newly-created wallet.
so := l.stakeOptions
cfg := &wallet.Config{
DB: db,
PubPassphrase: pubPassphrase,
VotingEnabled: so.VotingEnabled,
VotingEnabled: l.votingEnabled,
GapLimit: l.gapLimit,
WatchLast: l.watchLast,
AccountGapLimit: l.accountGapLimit,
Expand Down Expand Up @@ -313,11 +306,10 @@ func (l *Loader) OpenExistingWallet(ctx context.Context, pubPassphrase []byte) (
}
}()

so := l.stakeOptions
cfg := &wallet.Config{
DB: db,
PubPassphrase: pubPassphrase,
VotingEnabled: so.VotingEnabled,
VotingEnabled: l.votingEnabled,
GapLimit: l.gapLimit,
WatchLast: l.watchLast,
AccountGapLimit: l.accountGapLimit,
Expand Down
5 changes: 1 addition & 4 deletions walletsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ func displaySimnetMiningAddrs(seed []byte, imported bool) error {
// to do the initial sync.
func createWallet(ctx context.Context, cfg *config) error {
dbDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
stakeOptions := &loader.StakeOptions{
VotingEnabled: cfg.EnableVoting,
}
loader := loader.NewLoader(activeNet.Params, dbDir, stakeOptions,
loader := loader.NewLoader(activeNet.Params, dbDir, cfg.EnableVoting,
cfg.GapLimit, cfg.WatchLast, cfg.AllowHighFees, cfg.RelayFee.Amount,
cfg.AccountGapLimit, cfg.DisableCoinTypeUpgrades, !cfg.Mixing,
cfg.ManualTickets, cfg.MixSplitLimit)
Expand Down

0 comments on commit 5eff60a

Please sign in to comment.