Skip to content

Commit

Permalink
Merge pull request #214 from SiaFoundation/nate/skip-zero-valued-events
Browse files Browse the repository at this point in the history
Skip indexing zero-valued Siafund claim events
  • Loading branch information
n8maninger authored Jan 13, 2025
2 parents 3a76ce2 + 6c798e1 commit dc3c5ab
Show file tree
Hide file tree
Showing 3 changed files with 494 additions and 11 deletions.
4 changes: 2 additions & 2 deletions wallet/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate, indexMode IndexMode) e

// add new siacoin elements to the store
cau.ForEachSiacoinElement(func(se types.SiacoinElement, created, spent bool) {
if created && spent {
if (created && spent) || se.SiacoinOutput.Value.IsZero() {
return
}

Expand All @@ -113,7 +113,7 @@ func applyChainUpdate(tx UpdateTx, cau chain.ApplyUpdate, indexMode IndexMode) e
})

cau.ForEachSiafundElement(func(se types.SiafundElement, created, spent bool) {
if created && spent {
if (created && spent) || se.SiafundOutput.Value == 0 {
return
}

Expand Down
4 changes: 2 additions & 2 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, relevant f
}

sce, ok := sces[sfi.ParentID.ClaimOutputID()]
if ok && relevant(sce.SiacoinOutput.Address) {
if ok && relevant(sce.SiacoinOutput.Address) && !sce.SiacoinOutput.Value.IsZero() {
addEvent(types.Hash256(sce.ID), sce.MaturityHeight, EventTypeSiafundClaim, wallet.EventPayout{
SiacoinElement: sce,
}, []types.Address{sfi.ClaimAddress})
Expand Down Expand Up @@ -267,7 +267,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, relevant f
addresses[sfi.Parent.SiafundOutput.Address] = true

sce, ok := sces[types.SiafundOutputID(sfi.Parent.ID).V2ClaimOutputID()]
if ok && relevant(sfi.ClaimAddress) {
if ok && relevant(sfi.ClaimAddress) && !sce.SiacoinOutput.Value.IsZero() {
addEvent(types.Hash256(sce.ID), sce.MaturityHeight, EventTypeSiafundClaim, wallet.EventPayout{
SiacoinElement: sce,
}, []types.Address{sfi.ClaimAddress})
Expand Down
Loading

0 comments on commit dc3c5ab

Please sign in to comment.