From a9afb80a9a5ad3d28c2e850fc01ea4459d32a224 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Tue, 26 Nov 2024 10:31:34 +0100 Subject: [PATCH] rhp/v4: update handleRPCLatestRevision to return V2FileContractRevision rather than V2FileContract --- rhp/v4/rpc.go | 4 ++-- rhp/v4/server.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rhp/v4/rpc.go b/rhp/v4/rpc.go index 93d5973..f275c34 100644 --- a/rhp/v4/rpc.go +++ b/rhp/v4/rpc.go @@ -474,11 +474,11 @@ func RPCFundAccounts(ctx context.Context, t TransportClient, cs consensus.State, } // RPCLatestRevision returns the latest revision of a contract. -func RPCLatestRevision(ctx context.Context, t TransportClient, contractID types.FileContractID) (types.V2FileContract, error) { +func RPCLatestRevision(ctx context.Context, t TransportClient, contractID types.FileContractID) (types.V2FileContractRevision, error) { req := rhp4.RPCLatestRevisionRequest{ContractID: contractID} var resp rhp4.RPCLatestRevisionResponse err := callSingleRoundtripRPC(ctx, t, rhp4.RPCLatestRevisionID, &req, &resp) - return resp.Contract, err + return resp.Revision, err } // RPCSectorRoots returns the sector roots for a contract. diff --git a/rhp/v4/server.go b/rhp/v4/server.go index af45916..7cd0543 100644 --- a/rhp/v4/server.go +++ b/rhp/v4/server.go @@ -463,10 +463,19 @@ func (s *Server) handleRPCLatestRevision(stream net.Conn) error { if err != nil { return fmt.Errorf("failed to lock contract: %w", err) } + ci, fce, err := s.contractor.V2FileContractElement(req.ContractID) + if err != nil { + unlock() + return fmt.Errorf("failed to get contract's state element: %w", err) + } unlock() return rhp4.WriteResponse(stream, &rhp4.RPCLatestRevisionResponse{ - Contract: state.Revision, + ChainIndex: ci, + Revision: types.V2FileContractRevision{ + Parent: fce, + Revision: state.Revision, + }, }) }