From 0875745a2429bc05b95b47c43a8e824d9431df4a Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 12 Dec 2024 11:11:58 -0800 Subject: [PATCH 1/2] add revisable and renewed to RPCLatestRevision response --- .changeset/add_revisable_to_rpclatestrevision.md | 7 +++++++ rhp/v4/encoding.go | 4 ++++ rhp/v4/rhp.go | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/add_revisable_to_rpclatestrevision.md diff --git a/.changeset/add_revisable_to_rpclatestrevision.md b/.changeset/add_revisable_to_rpclatestrevision.md new file mode 100644 index 0000000..7305ae3 --- /dev/null +++ b/.changeset/add_revisable_to_rpclatestrevision.md @@ -0,0 +1,7 @@ +--- +default: major +--- + +# Add revisable to RPCLatestRevision + +Adds two additional flags to the RPCLatestRevision response. The `Revisable` field indicates whether the host will accept further revisions to the contract. A host will not accept revisions too close to the proof window or revisions on contracts that have already been resolved. The `Renewed` field indicates whether the contract was renewed. If the contract was renewed, the renter can use `FileContractID.V2RenewalID` to get the ID of the new contract. diff --git a/rhp/v4/encoding.go b/rhp/v4/encoding.go index 8172400..9bcb874 100644 --- a/rhp/v4/encoding.go +++ b/rhp/v4/encoding.go @@ -473,9 +473,13 @@ func (r *RPCLatestRevisionRequest) maxLen() int { func (r *RPCLatestRevisionResponse) encodeTo(e *types.Encoder) { r.Contract.EncodeTo(e) + e.WriteBool(r.Revisable) + e.WriteBool(r.Renewed) } func (r *RPCLatestRevisionResponse) decodeFrom(d *types.Decoder) { r.Contract.DecodeFrom(d) + r.Revisable = d.ReadBool() + r.Renewed = d.ReadBool() } func (r *RPCLatestRevisionResponse) maxLen() int { return sizeofContract diff --git a/rhp/v4/rhp.go b/rhp/v4/rhp.go index 05d1f16..61fe210 100644 --- a/rhp/v4/rhp.go +++ b/rhp/v4/rhp.go @@ -383,7 +383,9 @@ type ( } // RPCLatestRevisionResponse implements Object. RPCLatestRevisionResponse struct { - Contract types.V2FileContract `json:"contract"` + Contract types.V2FileContract `json:"contract"` + Revisable bool `json:"revisable"` + Renewed bool `json:"renewed"` } // RPCReadSectorRequest implements Object. From 8383d656cbed9a0aaa0e09edf1751e44043c2b31 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 12 Dec 2024 11:13:04 -0800 Subject: [PATCH 2/2] improve docstring --- rhp/v4/rhp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rhp/v4/rhp.go b/rhp/v4/rhp.go index 61fe210..c7004cc 100644 --- a/rhp/v4/rhp.go +++ b/rhp/v4/rhp.go @@ -382,6 +382,12 @@ type ( ContractID types.FileContractID `json:"contractID"` } // RPCLatestRevisionResponse implements Object. + // + // The `Revisable` field indicates whether the + // host will accept further revisions to the contract. A host will not accept revisions too + // close to the proof window or revisions on contracts that have already been resolved. + // The `Renewed` field indicates whether the contract was renewed. If the contract was + // renewed, the renter can use `FileContractID.V2RenewalID` to get the ID of the new contract. RPCLatestRevisionResponse struct { Contract types.V2FileContract `json:"contract"` Revisable bool `json:"revisable"`