Skip to content

Commit

Permalink
Merge pull request #230 from SiaFoundation/nate/json-consistency
Browse files Browse the repository at this point in the history
JSON consistency
  • Loading branch information
lukechampine authored Nov 12, 2024
2 parents 2a3a1bf + abd95cc commit a872ea8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion consensus/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func validateFileContracts(ms *MidState, txn types.Transaction, ts V1Transaction
return fmt.Errorf("file contract revision %v revises contract after its proof window has opened", i)
} else if fcr.FileContract.RevisionNumber <= parent.FileContract.RevisionNumber {
return fmt.Errorf("file contract revision %v does not have a higher revision number than its parent", i)
} else if types.Hash256(fcr.UnlockConditions.UnlockHash()) != parent.FileContract.UnlockHash {
} else if fcr.UnlockConditions.UnlockHash() != parent.FileContract.UnlockHash {
return fmt.Errorf("file contract revision %v claims incorrect unlock conditions", i)
}
outputSum := func(outputs []types.SiacoinOutput) (sum types.Currency) {
Expand Down
4 changes: 2 additions & 2 deletions consensus/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func prepareContractFormation(renterPubKey types.PublicKey, hostKey types.Public
WindowStart: endHeight,
WindowEnd: endHeight + windowSize,
Payout: payout,
UnlockHash: types.Hash256(uc.UnlockHash()),
UnlockHash: uc.UnlockHash(),
RevisionNumber: 0,
ValidProofOutputs: []types.SiacoinOutput{
{Value: renterPayout, Address: refundAddr},
Expand Down Expand Up @@ -1658,7 +1658,7 @@ func TestWindowRevision(t *testing.T) {
fc := types.FileContract{
WindowStart: 0,
WindowEnd: 3,
UnlockHash: types.Hash256(uc.UnlockHash()),
UnlockHash: uc.UnlockHash(),
}
genesisBlock.Transactions = []types.Transaction{{
FileContracts: []types.FileContract{fc},
Expand Down
2 changes: 1 addition & 1 deletion rhp/v2/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func PrepareContractFormation(renterPubKey types.PublicKey, hostKey types.Public
WindowStart: uint64(endHeight),
WindowEnd: uint64(endHeight + host.WindowSize),
Payout: payout,
UnlockHash: types.Hash256(uc.UnlockHash()),
UnlockHash: uc.UnlockHash(),
RevisionNumber: 0,
ValidProofOutputs: []types.SiacoinOutput{
// outputs need to account for tax
Expand Down
10 changes: 5 additions & 5 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ type FileContract struct {
Payout Currency `json:"payout"`
ValidProofOutputs []SiacoinOutput `json:"validProofOutputs"`
MissedProofOutputs []SiacoinOutput `json:"missedProofOutputs"`
UnlockHash Hash256 `json:"unlockHash"`
UnlockHash Address `json:"unlockHash"`
RevisionNumber uint64 `json:"revisionNumber"`
}

Expand Down Expand Up @@ -629,9 +629,9 @@ type StateElement struct {

// A ChainIndexElement is a record of a ChainIndex within the state accumulator.
type ChainIndexElement struct {
ID BlockID `json:"id"`
StateElement StateElement
ChainIndex ChainIndex `json:"chainIndex"`
ID BlockID `json:"id"`
StateElement StateElement `json:"stateElement"`
ChainIndex ChainIndex `json:"chainIndex"`
}

// A SiacoinElement is a record of a SiacoinOutput within the state accumulator.
Expand Down Expand Up @@ -1096,7 +1096,7 @@ func (fcr FileContractRevision) MarshalJSON() ([]byte, error) {
// Payout omitted; see FileContractRevision docstring
ValidProofOutputs []SiacoinOutput `json:"validProofOutputs"`
MissedProofOutputs []SiacoinOutput `json:"missedProofOutputs"`
UnlockHash Hash256 `json:"unlockHash"`
UnlockHash Address `json:"unlockHash"`
RevisionNumber uint64 `json:"revisionNumber"`
}{
fcr.ParentID,
Expand Down

0 comments on commit a872ea8

Please sign in to comment.