fix SectorsStatus to query full node for on-chain data
This commit is contained in:
parent
bed4c03a50
commit
51696bb35d
@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
@ -27,12 +26,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
|
|
||||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
|
|
||||||
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestPaymentChannelsBasic does a basic test to exercise the payment channel CLI
|
// TestPaymentChannelsBasic does a basic test to exercise the payment channel CLI
|
||||||
// commands
|
// commands
|
||||||
func TestPaymentChannelsBasic(t *testing.T) {
|
func TestPaymentChannelsBasic(t *testing.T) {
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||||
@ -52,7 +53,7 @@ func (rpn *retrievalProviderNode) GetMinerWorkerAddress(ctx context.Context, min
|
|||||||
|
|
||||||
func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (io.ReadCloser, error) {
|
func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (io.ReadCloser, error) {
|
||||||
log.Debugf("get sector %d, offset %d, length %d", sectorID, offset, length)
|
log.Debugf("get sector %d, offset %d, length %d", sectorID, offset, length)
|
||||||
si, err := rpn.secb.SectorsStatus(ctx, sectorID, false)
|
si, err := rpn.sectorsStatus(ctx, sectorID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -166,3 +167,37 @@ func (rpn *retrievalProviderNode) GetRetrievalPricingInput(ctx context.Context,
|
|||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rpn *retrievalProviderNode) sectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) {
|
||||||
|
sInfo, err := rpn.secb.SectorsStatus(ctx, sid, false)
|
||||||
|
if err != nil {
|
||||||
|
return api.SectorInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !showOnChainInfo {
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
onChainInfo, err := rpn.full.StateSectorGetInfo(ctx, rpn.maddr, sid, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return sInfo, err
|
||||||
|
}
|
||||||
|
if onChainInfo == nil {
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
sInfo.SealProof = onChainInfo.SealProof
|
||||||
|
sInfo.Activation = onChainInfo.Activation
|
||||||
|
sInfo.Expiration = onChainInfo.Expiration
|
||||||
|
sInfo.DealWeight = onChainInfo.DealWeight
|
||||||
|
sInfo.VerifiedDealWeight = onChainInfo.VerifiedDealWeight
|
||||||
|
sInfo.InitialPledge = onChainInfo.InitialPledge
|
||||||
|
|
||||||
|
ex, err := rpn.full.StateSectorExpiration(ctx, rpn.maddr, sid, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
sInfo.OnTime = ex.OnTime
|
||||||
|
sInfo.Early = ex.Early
|
||||||
|
|
||||||
|
return sInfo, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user