Skip to content

Commit

Permalink
reduce code duplication for v2 events
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 authored and ChrisSchinnerl committed Jan 7, 2025
1 parent e141e67 commit 781e9c9
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions explorer/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []
panic("unknown resolution type")
}

efc := V2FileContract{V2FileContractElement: fce}
{
element := sces[types.FileContractID(fce.ID).V2HostOutputID()]
addV2Resolution := func(element types.SiacoinElement) {
efc := V2FileContract{V2FileContractElement: fce}
addEvent(types.Hash256(element.ID), element.MaturityHeight, wallet.EventTypeV2ContractResolution, EventV2ContractResolution{
Resolution: V2FileContractResolution{
Parent: efc,
Expand All @@ -286,21 +285,10 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []
},
SiacoinElement: SiacoinOutput{SiacoinElement: element},
Missed: missed,
}, []types.Address{fce.V2FileContract.HostOutput.Address})
}

{
element := sces[types.FileContractID(fce.ID).V2RenterOutputID()]
addEvent(types.Hash256(element.ID), element.MaturityHeight, wallet.EventTypeV2ContractResolution, EventV2ContractResolution{
Resolution: V2FileContractResolution{
Parent: efc,
Type: typ,
Resolution: res,
},
SiacoinElement: SiacoinOutput{SiacoinElement: element},
Missed: missed,
}, []types.Address{fce.V2FileContract.RenterOutput.Address})
}, []types.Address{element.SiacoinOutput.Address})
}
addV2Resolution(sces[types.FileContractID(fce.ID).V2RenterOutputID()])
addV2Resolution(sces[types.FileContractID(fce.ID).V2HostOutputID()])
})

// handle block rewards
Expand Down

0 comments on commit 781e9c9

Please sign in to comment.