storageminer: Check on-chain commitments

This commit is contained in:
Łukasz Magiera 2019-10-29 22:41:28 +01:00
parent 44f4ee0de1
commit 3047c9d4c2
2 changed files with 12 additions and 15 deletions

View File

@ -141,15 +141,6 @@ func (ct *Tracker) WaitCommit(ctx context.Context, miner address.Address, sector
}
}
func (ct *Tracker) CheckCommitment(miner address.Address, sectorId uint64) (bool, error) {
key := commitmentKey(miner, sectorId)
ct.lk.Lock()
defer ct.lk.Unlock()
return ct.commitments.Has(key)
}
func (ct *Tracker) List() ([]api.SectorCommitment, error) {
out := make([]api.SectorCommitment, 0)

View File

@ -54,6 +54,7 @@ type storageMinerApi interface {
StateCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error)
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
StateMinerProvingPeriodEnd(context.Context, address.Address, *types.TipSet) (uint64, error)
StateMinerSectors(context.Context, address.Address, *types.TipSet) ([]*api.SectorInfo, error)
StateMinerProvingSet(context.Context, address.Address, *types.TipSet) ([]*api.SectorInfo, error)
StateMinerSectorSize(context.Context, address.Address, *types.TipSet) (uint64, error)
StateWaitMsg(context.Context, cid.Cid) (*api.MsgWait, error)
@ -100,13 +101,18 @@ func (m *Miner) commitUntrackedSectors(ctx context.Context) error {
return err
}
for _, s := range sealed {
has, err := m.commt.CheckCommitment(m.maddr, s.SectorID)
if err != nil {
log.Error("checking commitment: ", err)
}
chainSectors, err := m.api.StateMinerSectors(ctx, m.maddr, nil)
if err != nil {
return err
}
if has {
onchain := map[uint64]struct{}{}
for _, chainSector := range chainSectors {
onchain[chainSector.SectorID] = struct{}{}
}
for _, s := range sealed {
if _, ok := onchain[s.SectorID]; ok {
continue
}