SiaFoundation / renterd

A renter for Sia
https://sia.tech/software/renterd
MIT License
68 stars 20 forks source link

Add `host_sectors` table for sectors uploaded to temporary storage #1591

Open ChrisSchinnerl opened 1 month ago

ChrisSchinnerl commented 1 month ago

Before we get started with RHP4 in our upload code, we will need a new host_sectors table which maps all sectors to the host that they should be uploaded to. That way, we can track sectors which are uploaded but not part of a contract yet.

This will require at least the following changes:

  1. when an object is added to the bus, add a link to host_sectors for every sector.
  2. when an object is fetched from the bus, sectors which are uploaded but not linked to a contract should appear in the response with an empty slice of contract ids

Later, when we add upload pinning, we will be able to join sectors over both the contract_sectors as well as host_sectors to figure out which sectors still require pinning.

peterjan commented 1 month ago

@ChrisSchinnerl is the idea to keep host_sector once it's "upgraded" to a contract_sector? The changes you list make me think it's a yes while in my head that wasn't the case.

ChrisSchinnerl commented 1 month ago

@peterjan yeah the idea is to keep it. It's a permanent connection between a sector and a host that is only removed when the host reports it can't find the sector. Then we remove it from the host_sector and also contract_sector if we still got a contract that contains it. The latter leads to an incremented lost sectors count.