Make multiple deals per almost work

This commit is contained in:
Łukasz Magiera 2019-11-07 15:45:53 +01:00
parent 3fbe0abb75
commit 1549269773
2 changed files with 15 additions and 2 deletions

View File

@ -39,7 +39,7 @@ func (st *StateStore) Begin(i interface{}, state interface{}) error {
return err
}
if has {
return xerrors.Errorf("Already tracking state for %s", i)
return xerrors.Errorf("already tracking state for %v", i)
}
b, err := cborutil.Dump(state)
@ -111,12 +111,16 @@ func (st *StateStore) mutate(i interface{}, mutator func([]byte) ([]byte, error)
return st.ds.Put(k, mutated)
}
func (st *StateStore) Has(i interface{}) (bool, error) {
return st.ds.Has(toKey(i))
}
func (st *StateStore) Get(i interface{}, out cbg.CBORUnmarshaler) error {
k := toKey(i)
val, err := st.ds.Get(k)
if err != nil {
if xerrors.Is(err, datastore.ErrNotFound) {
return xerrors.Errorf("No state for %s", i)
return xerrors.Errorf("No state for %s: %w", i, err)
}
return err
}

View File

@ -61,6 +61,15 @@ func (m *Miner) sectorStateLoop(ctx context.Context) {
}
func (m *Miner) onSectorIncoming(sector *SectorInfo) {
has, err := m.sectors.Has(sector.SectorID)
if err != nil {
return
}
if has {
log.Warnf("SealSector called more than once for sector %d", sector.SectorID)
return
}
if err := m.sectors.Begin(sector.SectorID, sector); err != nil {
// We may have re-sent the proposal
log.Errorf("deal tracking failed: %s", err)