commitment tracker: prefer new commitments
This commit is contained in:
parent
b7a78670ab
commit
6c25c5384d
@ -60,6 +60,21 @@ func (ct *Tracker) TrackCommitSectorMsg(miner address.Address, sectorId uint64,
|
|||||||
|
|
||||||
tracking, err := ct.commitments.Get(key)
|
tracking, err := ct.commitments.Get(key)
|
||||||
switch err {
|
switch err {
|
||||||
|
case nil:
|
||||||
|
var comm commitment
|
||||||
|
if err := cbor.DecodeInto(tracking, &comm); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !comm.Msg.Equals(commitMsg) {
|
||||||
|
log.Errorf("commitment tracking for miner %s, sector %d: already tracking %s, got another commitment message: %s", miner, sectorId, comm.Msg, commitMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warnf("commitment.TrackCommitSectorMsg called more than once for miner %s, sector %d, message %s", miner, sectorId, commitMsg)
|
||||||
|
|
||||||
|
// we still want to store it
|
||||||
|
fallthrough // TODO: ideally we'd keep around both (even though we'll
|
||||||
|
// usually only need the new one)
|
||||||
case datastore.ErrNotFound:
|
case datastore.ErrNotFound:
|
||||||
comm := &commitment{Msg: commitMsg}
|
comm := &commitment{Msg: commitMsg}
|
||||||
commB, err := cbor.DumpObject(comm)
|
commB, err := cbor.DumpObject(comm)
|
||||||
@ -77,18 +92,6 @@ func (ct *Tracker) TrackCommitSectorMsg(miner address.Address, sectorId uint64,
|
|||||||
delete(ct.waits, key)
|
delete(ct.waits, key)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case nil:
|
|
||||||
var comm commitment
|
|
||||||
if err := cbor.DecodeInto(tracking, &comm); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !comm.Msg.Equals(commitMsg) {
|
|
||||||
return xerrors.Errorf("commitment tracking for miner %s, sector %d: already tracking %s, got another commitment message: %s", miner, sectorId, comm.Msg, commitMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Warnf("commitment.TrackCommitSectorMsg called more than once for miner %s, sector %d, message %s", miner, sectorId, commitMsg)
|
|
||||||
return nil
|
|
||||||
default:
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user