Strip unused functionality from sectorstore

This commit is contained in:
Łukasz Magiera 2019-11-01 11:05:48 +01:00
parent fc9091cc89
commit 1583cf2593
2 changed files with 4 additions and 69 deletions

View File

@ -13,7 +13,7 @@ type StateStore struct {
} }
func New(ds datastore.Datastore) *StateStore { func New(ds datastore.Datastore) *StateStore {
return &StateStore{ds:ds} return &StateStore{ds: ds}
} }
func (st *StateStore) Begin(i cid.Cid, state interface{}) error { func (st *StateStore) Begin(i cid.Cid, state interface{}) error {
@ -92,4 +92,3 @@ func (st *StateStore) List() ([]query.Entry, error) {
return out, nil return out, nil
} }

View File

@ -35,56 +35,18 @@ type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error)
// TODO: eventually handle sector storage here instead of in rust-sectorbuilder // TODO: eventually handle sector storage here instead of in rust-sectorbuilder
type Store struct { type Store struct {
waitingLk sync.Mutex
sb *sectorbuilder.SectorBuilder sb *sectorbuilder.SectorBuilder
tktFn TicketFn tktFn TicketFn
dealsLk sync.Mutex dealsLk sync.Mutex
deals datastore.Datastore deals datastore.Datastore
waiting map[uint64]chan struct{}
incoming []chan sectorbuilder.SectorSealingStatus
// TODO: outdated chan
closeCh chan struct{}
} }
func NewStore(sb *sectorbuilder.SectorBuilder, ds dtypes.MetadataDS, tktFn TicketFn) *Store { func NewStore(sb *sectorbuilder.SectorBuilder, ds dtypes.MetadataDS, tktFn TicketFn) *Store {
return &Store{ return &Store{
sb: sb, sb: sb,
tktFn: tktFn, tktFn: tktFn,
deals: namespace.Wrap(ds, sectorDealsPrefix), deals: namespace.Wrap(ds, sectorDealsPrefix),
waiting: map[uint64]chan struct{}{},
closeCh: make(chan struct{}),
}
}
func (s *Store) restartSealing() {
sectors, err := s.sb.GetAllStagedSectors()
if err != nil {
return
}
for _, sid := range sectors {
status, err := s.sb.SealStatus(sid)
if err != nil {
return
}
if status.State != sealing_state.CommittingPaused { // TODO: Also handle PreCommit!
continue
}
log.Infof("Sector %d is in paused state, resuming sealing", sid)
go func() {
// TODO: when we refactor wait-for-seal below, care about this output too
// (see SealSector below)
_, err := s.sb.ResumeSealCommit(sid)
if err != nil {
return
}
}()
} }
} }
@ -103,13 +65,6 @@ func (s *Store) AddPiece(ref string, size uint64, r io.Reader, dealIDs ...uint64
return 0, err return 0, err
} }
s.waitingLk.Lock()
_, exists := s.waiting[sectorID]
if !exists { // pieces can share sectors
s.waiting[sectorID] = make(chan struct{})
}
s.waitingLk.Unlock()
s.dealsLk.Lock() s.dealsLk.Lock()
defer s.dealsLk.Unlock() defer s.dealsLk.Unlock()
@ -205,21 +160,6 @@ func (s *Store) SealComputeProof(ctx context.Context, sectorID uint64, height ui
return sco.Proof, nil return sco.Proof, nil
} }
func (s *Store) WaitSeal(ctx context.Context, sector uint64) (sectorbuilder.SectorSealingStatus, error) {
s.waitingLk.Lock()
watch, ok := s.waiting[sector]
s.waitingLk.Unlock()
if ok {
select {
case <-watch:
case <-ctx.Done():
return sectorbuilder.SectorSealingStatus{}, ctx.Err()
}
}
return s.sb.SealStatus(sector)
}
func (s *Store) Commited() ([]sectorbuilder.SectorSealingStatus, error) { func (s *Store) Commited() ([]sectorbuilder.SectorSealingStatus, error) {
l, err := s.sb.GetAllStagedSectors() l, err := s.sb.GetAllStagedSectors()
if err != nil { if err != nil {
@ -265,7 +205,3 @@ func (s *Store) RunPoSt(ctx context.Context, sectors []*api.SectorInfo, r []byte
return s.sb.GeneratePoSt(ssi, seed, faults) return s.sb.GeneratePoSt(ssi, seed, faults)
} }
func (s *Store) Stop() {
close(s.closeCh)
}