cleaup, small refactor

This commit is contained in:
whyrusleeping 2019-09-17 19:55:51 -07:00
parent b1e77748e7
commit 9763810100
2 changed files with 19 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import (
amt "github.com/filecoin-project/go-amt-ipld" amt "github.com/filecoin-project/go-amt-ipld"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
@ -145,8 +146,22 @@ func GetMinerProvingSet(ctx context.Context, sm *StateManager, ts *types.TipSet,
return nil, xerrors.Errorf("failed to load miner actor state: %w", err) return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
} }
bs := amt.WrapBlockstore(sm.ChainStore().Blockstore()) return LoadSectorsFromSet(ctx, sm.ChainStore().Blockstore(), mas.ProvingSet)
a, err := amt.LoadAMT(bs, mas.ProvingSet) }
func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]*api.SectorInfo, error) {
var mas actors.StorageMinerActorState
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
}
return LoadSectorsFromSet(ctx, sm.ChainStore().Blockstore(), mas.Sectors)
}
func LoadSectorsFromSet(ctx context.Context, bs blockstore.Blockstore, ssc cid.Cid) ([]*api.SectorInfo, error) {
blks := amt.WrapBlockstore(bs)
a, err := amt.LoadAMT(blks, ssc)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -10,7 +10,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/go-lotus/api" "github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/chain"
"github.com/filecoin-project/go-lotus/chain/gen" "github.com/filecoin-project/go-lotus/chain/gen"
"github.com/filecoin-project/go-lotus/chain/store" "github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/chain/types" "github.com/filecoin-project/go-lotus/chain/types"
@ -105,8 +104,8 @@ func (tu *syncTestUtil) mineNewBlock(src int) {
} }
} }
func fblkToBlkMsg(fb *types.FullBlock) *chain.BlockMsg { func fblkToBlkMsg(fb *types.FullBlock) *types.BlockMsg {
out := &chain.BlockMsg{ out := &types.BlockMsg{
Header: fb.Header, Header: fb.Header,
} }