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