post: Address review
This commit is contained in:
parent
fdb45aeeaa
commit
5fd98b7d27
@ -33,7 +33,7 @@ type StorageMinerActorState struct {
|
||||
DePledgeTime types.BigInt
|
||||
|
||||
// All sectors this miner has committed.
|
||||
Sectors cid.Cid // TODO: Using a HAMT for now, needs to be an AMT once we implement it
|
||||
Sectors cid.Cid
|
||||
|
||||
// Sectors this miner is currently mining. It is only updated
|
||||
// when a PoSt is submitted (not as each new sector commitment is added).
|
||||
@ -295,7 +295,7 @@ type SubmitPoStParams struct {
|
||||
|
||||
// TODO: this is a dummy method that allows us to plumb in other parts of the
|
||||
// system for now.
|
||||
func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext, params *SubmitPoStParams) (_ []byte, paerr ActorError) {
|
||||
func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext, params *SubmitPoStParams) ([]byte, ActorError) {
|
||||
oldstate, self, err := loadState(vmctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -71,13 +71,13 @@ func (tsc *tipSetCache) get(height uint64) (*types.TipSet, error) {
|
||||
}
|
||||
|
||||
clen := len(tsc.cache)
|
||||
tailH := tsc.cache[((tsc.start-tsc.len+1)% clen + clen) % clen].Height()
|
||||
tailH := tsc.cache[((tsc.start-tsc.len+1)%clen+clen)%clen].Height()
|
||||
|
||||
if height < tailH {
|
||||
return tsc.storage(context.TODO(), height, tsc.cache[tailH])
|
||||
}
|
||||
|
||||
return tsc.cache[(int(height-tailH+1) % clen + clen) % clen], nil
|
||||
return tsc.cache[(int(height-tailH+1)%clen+clen)%clen], nil
|
||||
}
|
||||
|
||||
func (tsc *tipSetCache) best() *types.TipSet {
|
||||
|
@ -107,7 +107,10 @@ func (bi *BigInt) MarshalCBOR(w io.Writer) error {
|
||||
return zero.MarshalCBOR(w)
|
||||
}
|
||||
|
||||
tag := uint64(^(bi.Sign()|1)+6) >> 1
|
||||
tag := uint64(2)
|
||||
if bi.Sign() < 0 {
|
||||
tag = 3
|
||||
}
|
||||
|
||||
header := cbg.CborEncodeMajorType(cbg.MajTag, tag)
|
||||
if _, err := w.Write(header); err != nil {
|
||||
|
@ -70,6 +70,10 @@ func (vmc *VMContext) GetRandomness(height uint64) ([]byte, aerrors.ActorError)
|
||||
hts := vmc.vm.cs.GetHeaviestTipSet()
|
||||
|
||||
relHeight := int(hts.Height() - height)
|
||||
if relHeight < 0 {
|
||||
return nil, aerrors.Newf(1, "negative relHeight in GetRandomness: %d", relHeight)
|
||||
}
|
||||
|
||||
res, err := vmc.vm.cs.GetRandomness(vmc.ctx, hts, nil, relHeight)
|
||||
if err != nil {
|
||||
return nil, aerrors.Escalate(err, "could not get randomness")
|
||||
|
Loading…
Reference in New Issue
Block a user