Skip to content

Commit

Permalink
rhp/v4: update handleRPCLatestRevision to return V2FileContractRevisi…
Browse files Browse the repository at this point in the history
…on rather than V2FileContract
  • Loading branch information
ChrisSchinnerl committed Nov 26, 2024
1 parent 6172c9c commit a9afb80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions rhp/v4/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 481 in rhp/v4/rpc.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

resp.Revision undefined (type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse has no field or method Revision)

Check failure on line 481 in rhp/v4/rpc.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

resp.Revision undefined (type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse has no field or method Revision)

Check failure on line 481 in rhp/v4/rpc.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

resp.Revision undefined (type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse has no field or method Revision)
}

// RPCSectorRoots returns the sector roots for a contract.
Expand Down
11 changes: 10 additions & 1 deletion rhp/v4/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check failure on line 474 in rhp/v4/server.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

unknown field ChainIndex in struct literal of type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse

Check failure on line 474 in rhp/v4/server.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

unknown field ChainIndex in struct literal of type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse

Check failure on line 474 in rhp/v4/server.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

unknown field ChainIndex in struct literal of type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse
Revision: types.V2FileContractRevision{

Check failure on line 475 in rhp/v4/server.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

unknown field Revision in struct literal of type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse (typecheck)

Check failure on line 475 in rhp/v4/server.go

View workflow job for this annotation

GitHub Actions / test / test (1.22, ubuntu-latest)

unknown field Revision in struct literal of type "go.sia.tech/core/rhp/v4".RPCLatestRevisionResponse) (typecheck)
Parent: fce,
Revision: state.Revision,
},
})
}

Expand Down

0 comments on commit a9afb80

Please sign in to comment.