Skip to content

Commit

Permalink
Merge pull request #137 from SiaFoundation/nate/missing-resolution-type
Browse files Browse the repository at this point in the history
Missing resolution type
  • Loading branch information
ChrisSchinnerl authored Jun 20, 2024
2 parents 7aa00ce + 213b281 commit 610d7d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions persist/sqlite/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CREATE INDEX siacoin_elements_address_id ON siacoin_elements (address_id);
CREATE INDEX siacoin_elements_maturity_height_matured ON siacoin_elements (maturity_height, matured);
CREATE INDEX siacoin_elements_chain_index_id ON siacoin_elements (chain_index_id);
CREATE INDEX siacoin_elements_spent_index_id ON siacoin_elements (spent_index_id);
CREATE INDEX siacoin_elements_address_id_spent_index_id ON siacoin_elements(address_id, spent_index_id);

CREATE TABLE siafund_elements (
id BLOB PRIMARY KEY,
Expand All @@ -42,6 +43,7 @@ CREATE TABLE siafund_elements (
CREATE INDEX siafund_elements_address_id ON siafund_elements (address_id);
CREATE INDEX siafund_elements_chain_index_id ON siafund_elements (chain_index_id);
CREATE INDEX siafund_elements_spent_index_id ON siafund_elements (spent_index_id);
CREATE INDEX siafund_elements_address_id_spent_index_id ON siafund_elements(address_id, spent_index_id);

CREATE TABLE state_tree (
row INTEGER,
Expand Down
9 changes: 4 additions & 5 deletions wallet/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,17 @@ type (
// An EventV1ContractResolution represents a file contract payout from a v1
// contract.
EventV1ContractResolution struct {
FileContract types.FileContractElement `json:"fileContract"`
Parent types.FileContractElement `json:"parent"`
SiacoinElement types.SiacoinElement `json:"siacoinElement"`
Missed bool `json:"missed"`
}

// An EventV2ContractResolution represents a file contract payout from a v2
// contract.
EventV2ContractResolution struct {
FileContract types.V2FileContractElement `json:"fileContract"`
Resolution types.V2FileContractResolutionType `json:"resolution"`
SiacoinElement types.SiacoinElement `json:"siacoinElement"`
Missed bool `json:"missed"`
types.V2FileContractResolution
SiacoinElement types.SiacoinElement `json:"siacoinElement"`
Missed bool `json:"missed"`
}
)

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

outputID := types.FileContractID(fce.ID).ValidOutputID(i)
addEvent(types.Hash256(outputID), cs.MaturityHeight(), EventTypeV1ContractResolution, EventV1ContractResolution{
FileContract: fce,
Parent: fce,
SiacoinElement: sces[outputID],
Missed: false,
}, []types.Address{address})
Expand All @@ -294,7 +294,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, relevant f

outputID := types.FileContractID(fce.ID).MissedOutputID(i)
addEvent(types.Hash256(outputID), cs.MaturityHeight(), EventTypeV1ContractResolution, EventV1ContractResolution{
FileContract: fce,
Parent: fce,
SiacoinElement: sces[outputID],
Missed: true,
}, []types.Address{address})
Expand All @@ -315,8 +315,10 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, relevant f
if relevant(fce.V2FileContract.HostOutput.Address) {
outputID := types.FileContractID(fce.ID).V2HostOutputID()
addEvent(types.Hash256(outputID), cs.MaturityHeight(), EventTypeV2ContractResolution, EventV2ContractResolution{
FileContract: fce,
Resolution: res,
V2FileContractResolution: types.V2FileContractResolution{
Parent: fce,
Resolution: res,
},
SiacoinElement: sces[outputID],
Missed: missed,
}, []types.Address{fce.V2FileContract.HostOutput.Address})
Expand All @@ -325,8 +327,10 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, relevant f
if relevant(fce.V2FileContract.RenterOutput.Address) {
outputID := types.FileContractID(fce.ID).V2RenterOutputID()
addEvent(types.Hash256(outputID), cs.MaturityHeight(), EventTypeV2ContractResolution, EventV2ContractResolution{
FileContract: fce,
Resolution: res,
V2FileContractResolution: types.V2FileContractResolution{
Parent: fce,
Resolution: res,
},
SiacoinElement: sces[outputID],
Missed: missed,
}, []types.Address{fce.V2FileContract.RenterOutput.Address})
Expand Down

0 comments on commit 610d7d2

Please sign in to comment.