diff --git a/stores/metadata.go b/stores/metadata.go index 3a411838d5..2165ddacc9 100644 --- a/stores/metadata.go +++ b/stores/metadata.go @@ -1076,22 +1076,10 @@ func fetchUsedContracts(tx *gorm.DB, usedContracts map[types.PublicKey]types.Fil fcids = append(fcids, fileContractID(fcid)) } - // append the fcids with the renewed contracts - var archived []dbArchivedContract - if err := tx.Model(&dbArchivedContract{}). - Where("fcid IN (?)", fcids). - Find(&archived). - Error; err != nil { - return nil, err - } - for _, a := range archived { - fcids = append(fcids, fileContractID(a.RenewedTo)) - } - // fetch all contracts var contracts []dbContract if err := tx.Model(&dbContract{}). - Where("fcid IN (?)", fcids). + Where("fcid IN (?) OR renewed_from IN (?)", fcids). Preload("Host"). Find(&contracts).Error; err != nil { return nil, err