Merge pull request #210 from filecoin-project/fix/commit-track

fix error handling in track commit sector msg
This commit is contained in:
Łukasz Magiera 2019-09-19 16:36:31 +02:00 committed by GitHub
commit 88068b1cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,23 +56,6 @@ func (ct *Tracker) TrackCommitSectorMsg(miner address.Address, sectorId uint64,
tracking, err := ct.commitDs.Get(key)
switch err {
case datastore.ErrNotFound:
var comm commitment
if err := cbor.DecodeInto(tracking, &comm); err != nil {
return err
}
if !comm.Msg.Equals(mcid) {
return xerrors.Errorf("commitment tracking for miner %s, sector %d: already tracking %s, got another commitment message: %s", miner, sectorId, comm.Msg, mcid)
}
log.Warnf("commitment.TrackCommitSectorMsg called more than once for miner %s, sector %d, message %s", miner, sectorId, mcid)
return nil
case nil:
break
default:
return err
}
comm := &commitment{Msg: mcid}
commB, err := cbor.DumpObject(comm)
if err != nil {
@ -88,8 +71,22 @@ func (ct *Tracker) TrackCommitSectorMsg(miner address.Address, sectorId uint64,
close(waits)
delete(ct.waits, key)
}
return nil
case nil:
var comm commitment
if err := cbor.DecodeInto(tracking, &comm); err != nil {
return err
}
if !comm.Msg.Equals(mcid) {
return xerrors.Errorf("commitment tracking for miner %s, sector %d: already tracking %s, got another commitment message: %s", miner, sectorId, comm.Msg, mcid)
}
log.Warnf("commitment.TrackCommitSectorMsg called more than once for miner %s, sector %d, message %s", miner, sectorId, mcid)
return nil
default:
return err
}
}
func (ct *Tracker) WaitCommit(ctx context.Context, miner address.Address, sectorId uint64) (cid.Cid, error) {