sector import: More check progress
This commit is contained in:
parent
2318419291
commit
2b644525f8
@ -2,6 +2,8 @@ package sealing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -17,6 +19,15 @@ func (m *Sealing) Receive(ctx context.Context, meta api.RemoteSectorMeta) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err := m.sectors.Get(uint64(meta.Sector.Number)).Get(&cbg.Deferred{})
|
||||||
|
if errors.Is(err, datastore.ErrNotFound) {
|
||||||
|
|
||||||
|
} else if err != nil {
|
||||||
|
return xerrors.Errorf("checking if sector exists: %w", err)
|
||||||
|
} else if err == nil {
|
||||||
|
return xerrors.Errorf("sector %d state already exists", meta.Sector.Number)
|
||||||
|
}
|
||||||
|
|
||||||
panic("impl me")
|
panic("impl me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,27 +65,53 @@ func (m *Sealing) checkSectorMeta(ctx context.Context, meta api.RemoteSectorMeta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var info SectorInfo
|
||||||
|
|
||||||
switch SectorState(meta.State) {
|
switch SectorState(meta.State) {
|
||||||
case Packing:
|
case Proving, Available:
|
||||||
if err := checkPieces(ctx, m.maddr, meta.Sector.Number, meta.Pieces, m.Api, false); err != nil {
|
// todo possibly check
|
||||||
return xerrors.Errorf("checking pieces: %w", err)
|
info.CommitMessage = meta.CommitMessage
|
||||||
}
|
|
||||||
|
|
||||||
fallthrough
|
|
||||||
case GetTicket:
|
|
||||||
|
|
||||||
fallthrough
|
|
||||||
case PreCommitting:
|
|
||||||
|
|
||||||
fallthrough
|
fallthrough
|
||||||
case SubmitCommit:
|
case SubmitCommit:
|
||||||
|
info.PreCommitInfo = meta.PreCommitInfo
|
||||||
|
info.PreCommitDeposit = meta.PreCommitDeposit
|
||||||
|
info.PreCommitMessage = meta.PreCommitMessage
|
||||||
|
info.PreCommitTipSet = meta.PreCommitTipSet
|
||||||
|
|
||||||
|
// todo check
|
||||||
|
info.SeedValue = meta.SeedValue
|
||||||
|
info.SeedEpoch = meta.SeedEpoch
|
||||||
|
|
||||||
|
// todo validate
|
||||||
|
info.Proof = meta.CommitProof
|
||||||
|
|
||||||
fallthrough
|
fallthrough
|
||||||
case Proving, Available:
|
case PreCommitting:
|
||||||
|
info.TicketValue = meta.TicketValue
|
||||||
|
info.TicketEpoch = meta.TicketEpoch
|
||||||
|
|
||||||
|
info.PreCommit1Out = meta.PreCommit1Out
|
||||||
|
|
||||||
|
info.CommD = meta.CommD // todo check cid prefixes
|
||||||
|
info.CommR = meta.CommR
|
||||||
|
|
||||||
|
fallthrough
|
||||||
|
case GetTicket:
|
||||||
|
fallthrough
|
||||||
|
case Packing:
|
||||||
|
// todo check num free
|
||||||
|
info.State = SectorState(meta.State) // todo dedupe states
|
||||||
|
info.SectorNumber = meta.Sector.Number
|
||||||
|
info.Pieces = meta.Pieces
|
||||||
|
info.SectorType = meta.Type
|
||||||
|
|
||||||
|
if err := checkPieces(ctx, m.maddr, meta.Sector.Number, meta.Pieces, m.Api, false); err != nil {
|
||||||
|
return xerrors.Errorf("checking pieces: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return xerrors.Errorf("imported sector State in not supported")
|
return xerrors.Errorf("imported sector State in not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user