Skip to content

Archive contracts instead of deleting them

Luke Champine requested to merge contract-archive into master

Contracts are now moved to a new contractor map, oldContracts, instead of being deleted. This map is not used anywhere, but it may be used in the future (e.g. for calculating historic metrics).

An alternative would be to store all contracts (including current ones) in this new map. I haven't thought through what the tradeoffs of that approach are.

Also, a new "secret" method has been added to the contractor, AllContracts. This method returns all the contracts in the current period, whereas Contracts filters out offline contracts. It's "secret" because it's not actually part of the contractor (or renter) interface; the API uses a type assertion to access it. This is because the method isn't intended to stick around.

I am much more in favor of moving the offline filtering into the renter, and having Contracts return the offline contracts. Since determining the offline status of a host doesn't require any unexported contractor functionality, the renter could define its own onlineContracts helper function and call it wherever we call r.hostContractor.Contracts, which is only 3 places. The only reason not to do this is to avoid code duplication between the renter and contractor. (The contract still needs to filter out offline contracts so that it can replace them.) We could, however, move this functionality to the modules package.

Merge request reports