-
Notifications
You must be signed in to change notification settings - Fork 439
Conversation
And you need to update the api documentation for the /renter/contracts endpoint to reflect that old contracts are now returned as well. And... we should consider having the old contracts get returned as a flag instead of always getting returned, because over time that will build up to be a bunch of data. |
Are you saying to look for the flag in |
I also went ahead and renamed |
7e0da14
to
9315ef1
Compare
Yeah, add a bool so that it only returns the expired contract if a flag is passed in, that way long running renters don't have to worry about getting 50,000 returned objects when they make a query. |
cmd/siac/rentercmd.go
Outdated
@@ -475,11 +477,11 @@ func rentercontractscmd() { | |||
// rentercontractsviewcmd is the handler for the command `siac renter contracts <id>`. | |||
// It lists details of a specific contract. | |||
func rentercontractsviewcmd(cid string) { | |||
rc, err := httpClient.RenterContractsGet() | |||
rc, err := httpClient.RenterContractsGet(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it's not obvious at all what true
means in the context of this function, convention is to use a variable:
getAllContracts := true
rc, err := httpCliend.RenterContractsGet(getAllContracts)
cmd/siac/export.go
Outdated
@@ -30,13 +30,12 @@ var ( | |||
// renterexportcontracttxnscmd is the handler for the command `siac renter export contract-txns`. | |||
// Exports the current contract set to JSON. | |||
func renterexportcontracttxnscmd(destination string) { | |||
cs, err := httpClient.RenterContractsGet() | |||
cs, err := httpClient.RenterContractsGet(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it's not obvious at all what true
means in the context of this function, convention is to use a variable:
getAllContracts := true
rc, err := httpCliend.RenterContractsGet(getAllContracts)
This comment has been minimized.
This comment has been minimized.
That distinction looks good to me. |
…for contracts summary
This comment has been minimized.
This comment has been minimized.
cmd/siac/rentercmd.go
Outdated
if renterAllContracts { | ||
if len(rc.OldContracts) == 0 { | ||
rc, err := httpClient.RenterExpiredContractsGet() |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
cmd/siac/rentercmd.go
Outdated
|
||
for _, rc := range contracts { | ||
for _, rc := range rc.Contracts { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
modules/renter/renter.go
Outdated
@@ -113,7 +113,7 @@ type hostContractor interface { | |||
// Contracts returns the active contracts formed by the contractor. | |||
Contracts() []modules.RenterContract | |||
|
|||
// Contracts returns the old contracts formed by the contractor. | |||
// OldContracts returns the Expired contracts formed by the contractor. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
node/api/renter.go
Outdated
// | ||
// Inactive contracts are contracts that are not currently being used by the | ||
// renter because they are either !goodForUpload or !goodForRenew, but have | ||
// endheights that are in the future so could potentially become active again |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
siatest/renter/renter_test.go
Outdated
@@ -1339,64 +1383,219 @@ func TestRenterOldContracts(t *testing.T) { | |||
} | |||
tg, err := siatest.NewGroupFromTemplate(groupParams) | |||
if err != nil { | |||
t.Fatal("Failed to create group: ", err) | |||
t.Fatal("Failed to get files") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
siatest/renter/renter_test.go
Outdated
// TestRenterResetAllowance tests that resetting the allowance after the | ||
// allowance was cancelled will trigger the correct contract formation. | ||
// TestRenterCancelAllowance tests that setting an empty allowance causes | ||
// uploads, downloads, and renewals to cease. | ||
func TestRenterResetAllowance(t *testing.T) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
siatest/renter/renter_test.go
Outdated
@@ -1668,6 +1870,7 @@ func TestRenterSpendingReporting(t *testing.T) { | |||
} | |||
|
|||
// Get renter's initial siacoin balance | |||
r := tg.Renters()[0] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
siatest/renter/renter_test.go
Outdated
@@ -2016,8 +2251,6 @@ func TestRenterSpendingReporting(t *testing.T) { | |||
} | |||
} | |||
|
|||
// The following are helper functions for the renter tests | |||
|
|||
// checkBalanceVsSpending checks the renters confirmed siacoin balance in their |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
7e36187
to
a1536e4
Compare
if expired && c.EndHeight < blockHeight { | ||
expiredContracts = append(expiredContracts, contract) | ||
} else if inactive && c.EndHeight >= blockHeight { | ||
inactiveContracts = append(inactiveContracts, contract) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be two separate if
s, not an else if
? What if you want both expired and inactive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no contract will be both inactive and expired, this is fine. We should add a comment though.
Removed old contracts from Export to avoid breaking backwards compatibility.
Updated releaseblock calculation.
@DavidVorick if there are other edits you find during your review please add TODO's to this PR so we can merge them in.