Skip to content

Commit

Permalink
testutil: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Feb 13, 2024
1 parent cd67e62 commit 5adccd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 4 additions & 2 deletions testutil/wallet.go
Expand Up @@ -29,9 +29,9 @@ type (
}
)

func (et *ephemeralWalletUpdateTxn) WalletStateElements() (eles []types.StateElement, _ error) {
func (et *ephemeralWalletUpdateTxn) WalletStateElements() (elements []types.StateElement, _ error) {
for _, se := range et.store.utxos {
eles = append(eles, se.StateElement)
elements = append(elements, se.StateElement)
}
return
}
Expand Down Expand Up @@ -133,6 +133,7 @@ func (es *EphemeralWalletStore) Tip() (types.ChainIndex, error) {
return es.tip, nil
}

// ProcessChainApplyUpdate implements chain.Subscriber.
func (es *EphemeralWalletStore) ProcessChainApplyUpdate(cau *chain.ApplyUpdate, mayCommit bool) error {
es.mu.Lock()
defer es.mu.Unlock()
Expand All @@ -153,6 +154,7 @@ func (es *EphemeralWalletStore) ProcessChainApplyUpdate(cau *chain.ApplyUpdate,
return nil
}

// ProcessChainRevertUpdate implements chain.Subscriber.
func (es *EphemeralWalletStore) ProcessChainRevertUpdate(cru *chain.RevertUpdate) error {
es.mu.Lock()
defer es.mu.Unlock()
Expand Down
13 changes: 6 additions & 7 deletions wallet/wallet.go
Expand Up @@ -213,7 +213,7 @@ func (sw *SingleAddressWallet) FundTransaction(txn *types.Transaction, amount ty
sw.mu.Lock()
defer sw.mu.Unlock()

utxos, err := sw.store.UnspentSiacoinElements()
elements, err := sw.store.UnspentSiacoinElements()
if err != nil {
return nil, nil, err
}
Expand All @@ -236,14 +236,13 @@ func (sw *SingleAddressWallet) FundTransaction(txn *types.Transaction, amount ty
}

// remove locked and spent outputs
filtered := utxos[:0]
for _, sce := range utxos {
utxos := make([]types.SiacoinElement, 0, len(elements))
for _, sce := range elements {
if time.Now().Before(sw.locked[sce.ID]) || tpoolSpent[sce.ID] {
continue
}
filtered = append(filtered, sce)
utxos = append(utxos, sce.SiacoinElement)
}
utxos = filtered

// sort by value, descending
sort.Slice(utxos, func(i, j int) bool {
Expand Down Expand Up @@ -273,7 +272,7 @@ func (sw *SingleAddressWallet) FundTransaction(txn *types.Transaction, amount ty
utxos = utxos[i:]
break
}
selected = append(selected, sce.SiacoinElement)
selected = append(selected, sce)
inputSum = inputSum.Add(sce.SiacoinOutput.Value)
}

Expand Down Expand Up @@ -309,7 +308,7 @@ func (sw *SingleAddressWallet) FundTransaction(txn *types.Transaction, amount ty
}

sce := defraggable[i]
selected = append(selected, sce.SiacoinElement)
selected = append(selected, sce)
inputSum = inputSum.Add(sce.SiacoinOutput.Value)
txnInputs++
}
Expand Down

0 comments on commit 5adccd9

Please sign in to comment.