Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON consistency #230

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
lukechampine marked this conversation as resolved.
Show resolved Hide resolved
RevisionNumber uint64 `json:"revisionNumber"`
}{
fcr.ParentID,
Expand Down
Loading