Some smaller fixes
This commit is contained in:
parent
2fe1b5a538
commit
1dcebece71
@ -228,7 +228,7 @@ func (sma StorageMinerActor) PreCommitSector(act *types.Actor, vmctx types.VMCon
|
||||
}
|
||||
|
||||
if params.Epoch >= vmctx.BlockHeight() {
|
||||
return nil, aerrors.New(1, "sector commitment must be based off past randomness")
|
||||
return nil, aerrors.Newf(1, "sector commitment must be based off past randomness (%d >= %d)", params.Epoch, vmctx.BlockHeight())
|
||||
}
|
||||
|
||||
if vmctx.BlockHeight()-params.Epoch > 1000 {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
)
|
||||
|
||||
var log = logging.Logger("types")
|
||||
@ -52,6 +53,10 @@ func (ts *TipSet) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
func (ts *TipSet) MarshalCBOR(w io.Writer) error {
|
||||
if ts == nil {
|
||||
_, err := w.Write(cbg.CborNull)
|
||||
return err
|
||||
}
|
||||
return (&ExpTipSet{
|
||||
Cids: ts.cids,
|
||||
Blocks: ts.blks,
|
||||
|
@ -74,8 +74,8 @@ func cborMutator(mutator interface{}) func([]byte) ([]byte, error) {
|
||||
|
||||
out := rmut.Call([]reflect.Value{state})
|
||||
|
||||
if err := out[0].Interface().(error); err != nil {
|
||||
return nil, err
|
||||
if err := out[0].Interface(); err != nil {
|
||||
return nil, err.(error)
|
||||
}
|
||||
|
||||
return cborrpc.Dump(state.Interface())
|
||||
|
@ -9,12 +9,15 @@ const stateGettingToken = 'getting-token'
|
||||
|
||||
let sealCodes = [
|
||||
"Unknown",
|
||||
"Pending",
|
||||
"AcceptingPieces",
|
||||
"Committed",
|
||||
"Committing",
|
||||
"CommittingPaused",
|
||||
"Failed",
|
||||
"Sealing",
|
||||
"Sealed",
|
||||
"Paused",
|
||||
"ReadyForSealing",
|
||||
"FullyPacked",
|
||||
"PreCommitted",
|
||||
"PreCommitting",
|
||||
"PreCommittingPaused",
|
||||
]
|
||||
|
||||
class StorageNode extends React.Component {
|
||||
|
@ -90,7 +90,7 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.t.State (api.SectorState)
|
||||
// t.t.State (uint64)
|
||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, t.State)); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -173,7 +173,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
return fmt.Errorf("cbor input had wrong number of fields")
|
||||
}
|
||||
|
||||
// t.t.State (api.SectorState)
|
||||
// t.t.State (uint64)
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
|
@ -80,6 +80,11 @@ func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datasto
|
||||
secst: secst,
|
||||
|
||||
sectors: statestore.New(namespace.Wrap(ds, datastore.NewKey("/sectors"))),
|
||||
|
||||
sectorIncoming: make(chan *SectorInfo),
|
||||
sectorUpdated: make(chan sectorUpdate),
|
||||
stop: make(chan struct{}),
|
||||
stopped: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -81,15 +81,18 @@ func (m *Miner) onSectorIncoming(sector *SectorInfo) {
|
||||
}
|
||||
|
||||
func (m *Miner) onSectorUpdated(ctx context.Context, update sectorUpdate) {
|
||||
log.Infof("Sector %s updated state to %s", update.id, api.SectorStateStr(update.newState))
|
||||
log.Infof("Sector %d updated state to %s", update.id, api.SectorStateStr(update.newState))
|
||||
var sector SectorInfo
|
||||
err := m.sectors.Mutate(update.id, func(s *SectorInfo) error {
|
||||
s.State = update.newState
|
||||
if update.mut != nil {
|
||||
update.mut(s)
|
||||
}
|
||||
sector = *s
|
||||
return nil
|
||||
})
|
||||
if update.err != nil {
|
||||
log.Errorf("deal %s failed: %s", update.id, update.err)
|
||||
log.Errorf("sector %d failed: %s", update.id, update.err)
|
||||
m.failSector(update.id, update.err)
|
||||
return
|
||||
}
|
||||
@ -111,10 +114,13 @@ func (m *Miner) onSectorUpdated(ctx context.Context, update sectorUpdate) {
|
||||
}
|
||||
|
||||
func (m *Miner) failSector(id uint64, err error) {
|
||||
log.Error(err)
|
||||
panic(err) // todo: better error handling strategy
|
||||
}
|
||||
|
||||
func (m *Miner) SealSector(ctx context.Context, sid uint64) error {
|
||||
log.Infof("Begin sealing sector %d", sid)
|
||||
|
||||
si := &SectorInfo{
|
||||
State: api.UndefinedSectorState,
|
||||
SectorID: sid,
|
||||
|
Loading…
Reference in New Issue
Block a user