Skip to content

Commit

Permalink
Merge pull request #45 from SiaFoundation/pj/fix-utxo-values
Browse files Browse the repository at this point in the history
Cache ephemeral utxo values
  • Loading branch information
n8maninger committed Apr 16, 2024
2 parents 6dc8ac8 + fe8a472 commit c7958e8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wallet/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,18 @@ func applyChainState(tx UpdateTx, address types.Address, cau chain.ApplyUpdate)
utxoValues := make(map[types.SiacoinOutputID]types.Currency)

cau.ForEachSiacoinElement(func(se types.SiacoinElement, spent bool) {
if se.SiacoinOutput.Address != address || ephemeral[types.Hash256(se.ID)] {
if se.SiacoinOutput.Address != address {
return
}

// cache the value of the utxo to use when calculating outflow
utxoValues[types.SiacoinOutputID(se.ID)] = se.SiacoinOutput.Value

// ignore ephemeral elements
if ephemeral[se.ID] {
return
}

if spent {
spentUTXOs = append(spentUTXOs, se)
} else {
Expand Down

0 comments on commit c7958e8

Please sign in to comment.