Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Updates on Spend Reporting PR 3087 #3131

Merged
merged 27 commits into from
Jul 12, 2018
Merged

Updates on Spend Reporting PR 3087 #3131

merged 27 commits into from
Jul 12, 2018

Conversation

MSevey
Copy link
Contributor

@MSevey MSevey commented Jun 29, 2018

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.

@DavidVorick
Copy link
Member

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.

@MSevey
Copy link
Contributor Author

MSevey commented Jul 2, 2018

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 renterContractsHandler so that only the active contracts are returned unless the flag is provided? So adding like an oldContracts bool or something?

@MSevey
Copy link
Contributor Author

MSevey commented Jul 2, 2018

I also went ahead and renamed OldContracts to ExpiredContracts since active and expired make more sense than active and old.

@MSevey MSevey force-pushed the 3087-fixes branch 3 times, most recently from 7e0da14 to 9315ef1 Compare July 2, 2018 19:25
@DavidVorick
Copy link
Member

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.

@@ -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)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

@MSevey

This comment has been minimized.

@DavidVorick
Copy link
Member

That distinction looks good to me. inactive would include contracts that have been renewed due to depletion? (I think it would, as they would be !goodForRewew)

@MSevey MSevey added this to the v1.3.4 milestone Jul 3, 2018
@MSevey MSevey added the v1.3.4 label Jul 3, 2018
@MSevey

This comment has been minimized.

if renterAllContracts {
if len(rc.OldContracts) == 0 {
rc, err := httpClient.RenterExpiredContractsGet()

This comment was marked as resolved.


for _, rc := range contracts {
for _, rc := range rc.Contracts {

This comment was marked as resolved.

@@ -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.

//
// 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.

@@ -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.

// 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.

@@ -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.

@@ -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.

@MSevey
Copy link
Contributor Author

MSevey commented Jul 10, 2018

test-long is passing locally

@MSevey MSevey force-pushed the 3087-fixes branch 2 times, most recently from 7e36187 to a1536e4 Compare July 10, 2018 22:03
@MSevey
Copy link
Contributor Author

MSevey commented Jul 11, 2018

siac renter contracts

image

@MSevey
Copy link
Contributor Author

MSevey commented Jul 11, 2018

siac renter contracts -A
image

@MSevey
Copy link
Contributor Author

MSevey commented Jul 11, 2018

siac if no contracts have been formed
image

@MSevey
Copy link
Contributor Author

MSevey commented Jul 11, 2018

fixed column headers
image

if expired && c.EndHeight < blockHeight {
expiredContracts = append(expiredContracts, contract)
} else if inactive && c.EndHeight >= blockHeight {
inactiveContracts = append(inactiveContracts, contract)
Copy link
Member

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 ifs, not an else if? What if you want both expired and inactive?

Copy link
Member

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.

@lukechampine lukechampine merged commit 9f8d535 into master Jul 12, 2018
@MSevey MSevey deleted the 3087-fixes branch July 16, 2018 17:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants