Skip to content

Commit

Permalink
Some smaller fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Nov 1, 2019
1 parent 2fe1b5a commit 1dcebec
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion chain/actors/actor_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions chain/types/tipset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/statestore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
13 changes: 8 additions & 5 deletions lotuspond/front/src/StorageNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions storage/cbor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions storage/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 8 additions & 2 deletions storage/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand Down

0 comments on commit 1dcebec

Please sign in to comment.