storage: Move control address logic to storage/ctladdr
This commit is contained in:
parent
dff1bf2868
commit
717bda63b1
@ -22,7 +22,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/node/modules"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
)
|
||||
|
||||
func TestPublishDealsBatching(t *testing.T) {
|
||||
@ -51,7 +51,7 @@ func TestPublishDealsBatching(t *testing.T) {
|
||||
MaxDealsPerMsg: maxDealsPerMsg,
|
||||
}),
|
||||
),
|
||||
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
DealPublishControl: []string{
|
||||
publisherKey.Address.String(),
|
||||
},
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/node/modules"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -52,7 +52,7 @@ func TestDealsRetryLackOfFunds(t *testing.T) {
|
||||
MaxDealsPerMsg: maxDealsPerMsg,
|
||||
}),
|
||||
),
|
||||
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
DealPublishControl: []string{
|
||||
publishStorageDealKey.Address.String(),
|
||||
},
|
||||
@ -128,7 +128,7 @@ func TestDealsRetryLackOfFunds_blockInPublishDeal(t *testing.T) {
|
||||
MaxDealsPerMsg: maxDealsPerMsg,
|
||||
}),
|
||||
),
|
||||
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
DealPublishControl: []string{
|
||||
publishStorageDealKey.Address.String(),
|
||||
},
|
||||
@ -201,7 +201,7 @@ func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) {
|
||||
MaxDealsPerMsg: maxDealsPerMsg,
|
||||
}),
|
||||
),
|
||||
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
node.Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
||||
DealPublishControl: []string{
|
||||
publishStorageDealKey.Address.String(),
|
||||
},
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
)
|
||||
|
||||
type dealPublisherAPI interface {
|
||||
@ -48,7 +48,7 @@ type dealPublisherAPI interface {
|
||||
// publish message with all deals in the queue.
|
||||
type DealPublisher struct {
|
||||
api dealPublisherAPI
|
||||
as *storage.AddressSelector
|
||||
as *ctladdr.AddressSelector
|
||||
|
||||
ctx context.Context
|
||||
Shutdown context.CancelFunc
|
||||
@ -99,8 +99,8 @@ type PublishMsgConfig struct {
|
||||
func NewDealPublisher(
|
||||
feeConfig *config.MinerFeeConfig,
|
||||
publishMsgCfg PublishMsgConfig,
|
||||
) func(lc fx.Lifecycle, full api.FullNode, as *storage.AddressSelector) *DealPublisher {
|
||||
return func(lc fx.Lifecycle, full api.FullNode, as *storage.AddressSelector) *DealPublisher {
|
||||
) func(lc fx.Lifecycle, full api.FullNode, as *ctladdr.AddressSelector) *DealPublisher {
|
||||
return func(lc fx.Lifecycle, full api.FullNode, as *ctladdr.AddressSelector) *DealPublisher {
|
||||
maxFee := abi.NewTokenAmount(0)
|
||||
if feeConfig != nil {
|
||||
maxFee = abi.TokenAmount(feeConfig.MaxPublishDealsFee)
|
||||
@ -119,7 +119,7 @@ func NewDealPublisher(
|
||||
|
||||
func newDealPublisher(
|
||||
dpapi dealPublisherAPI,
|
||||
as *storage.AddressSelector,
|
||||
as *ctladdr.AddressSelector,
|
||||
publishMsgCfg PublishMsgConfig,
|
||||
publishSpec *api.MessageSendSpec,
|
||||
) *DealPublisher {
|
||||
|
@ -37,6 +37,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
@ -51,7 +52,7 @@ var MinerNode = Options(
|
||||
Override(new(dtypes.NetworkName), modules.StorageNetworkName),
|
||||
|
||||
// Mining / proving
|
||||
Override(new(*storage.AddressSelector), modules.AddressSelector(nil)),
|
||||
Override(new(*ctladdr.AddressSelector), modules.AddressSelector(nil)),
|
||||
)
|
||||
|
||||
func ConfigStorageMiner(c interface{}) Option {
|
||||
@ -221,7 +222,7 @@ func ConfigStorageMiner(c interface{}) Option {
|
||||
),
|
||||
|
||||
Override(new(sectorstorage.Config), cfg.StorageManager()),
|
||||
Override(new(*storage.AddressSelector), modules.AddressSelector(&cfg.Addresses)),
|
||||
Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&cfg.Addresses)),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/miner"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
@ -90,7 +91,7 @@ type StorageMinerAPI struct {
|
||||
IStorageMgr sectorstorage.SectorManager `optional:"true"`
|
||||
stores.SectorIndex
|
||||
storiface.WorkerReturn `optional:"true"`
|
||||
AddrSel *storage.AddressSelector
|
||||
AddrSel *ctladdr.AddressSelector
|
||||
|
||||
WdPoSt *wdpost.WindowPoStScheduler `optional:"true"`
|
||||
|
||||
|
@ -70,6 +70,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||
)
|
||||
|
||||
@ -151,9 +152,9 @@ func SectorIDCounter(ds dtypes.MetadataDS) sealing.SectorIDCounter {
|
||||
return &sidsc{sc}
|
||||
}
|
||||
|
||||
func AddressSelector(addrConf *config.MinerAddressConfig) func() (*storage.AddressSelector, error) {
|
||||
return func() (*storage.AddressSelector, error) {
|
||||
as := &storage.AddressSelector{}
|
||||
func AddressSelector(addrConf *config.MinerAddressConfig) func() (*ctladdr.AddressSelector, error) {
|
||||
return func() (*ctladdr.AddressSelector, error) {
|
||||
as := &ctladdr.AddressSelector{}
|
||||
if addrConf == nil {
|
||||
return as, nil
|
||||
}
|
||||
@ -214,7 +215,7 @@ type StorageMinerParams struct {
|
||||
Prover ffiwrapper.Prover
|
||||
GetSealingConfigFn dtypes.GetSealingConfigFunc
|
||||
Journal journal.Journal
|
||||
AddrSel *storage.AddressSelector
|
||||
AddrSel *ctladdr.AddressSelector
|
||||
Maddr dtypes.MinerAddress
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package storage
|
||||
package ctladdr
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
@ -11,6 +13,8 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var log = logging.Logger("ctladdr")
|
||||
|
||||
type addrSelectApi interface {
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
WalletHas(context.Context, address.Address) (bool, error)
|
@ -34,6 +34,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
)
|
||||
|
||||
var log = logging.Logger("storageminer")
|
||||
@ -54,7 +55,7 @@ type Miner struct {
|
||||
sc sealing.SectorIDCounter
|
||||
verif ffiwrapper.Verifier
|
||||
prover ffiwrapper.Prover
|
||||
addrSel *AddressSelector
|
||||
addrSel *ctladdr.AddressSelector
|
||||
|
||||
maddr address.Address
|
||||
|
||||
@ -139,7 +140,7 @@ func NewMiner(api fullNodeFilteredAPI,
|
||||
gsd dtypes.GetSealingConfigFunc,
|
||||
feeCfg config.MinerFeeConfig,
|
||||
journal journal.Journal,
|
||||
as *AddressSelector) (*Miner, error) {
|
||||
as *ctladdr.AddressSelector) (*Miner, error) {
|
||||
m := &Miner{
|
||||
api: api,
|
||||
feeCfg: feeCfg,
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
storage2 "github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
)
|
||||
|
||||
type mockStorageMinerAPI struct {
|
||||
@ -237,7 +237,7 @@ func TestWDPostDoPost(t *testing.T) {
|
||||
proofType: proofType,
|
||||
actor: postAct,
|
||||
journal: journal.NilJournal(),
|
||||
addrSel: &storage2.AddressSelector{},
|
||||
addrSel: &ctladdr.AddressSelector{},
|
||||
}
|
||||
|
||||
di := &dline.Info{
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
storage2 "github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||
)
|
||||
|
||||
var log = logging.Logger("wdpost")
|
||||
@ -65,7 +65,7 @@ type NodeAPI interface {
|
||||
type WindowPoStScheduler struct {
|
||||
api NodeAPI
|
||||
feeCfg config.MinerFeeConfig
|
||||
addrSel *storage2.AddressSelector
|
||||
addrSel *ctladdr.AddressSelector
|
||||
prover storage.Prover
|
||||
verifier ffiwrapper.Verifier
|
||||
faultTracker sectorstorage.FaultTracker
|
||||
@ -85,7 +85,7 @@ type WindowPoStScheduler struct {
|
||||
// NewWindowedPoStScheduler creates a new WindowPoStScheduler scheduler.
|
||||
func NewWindowedPoStScheduler(api NodeAPI,
|
||||
cfg config.MinerFeeConfig,
|
||||
as *storage2.AddressSelector,
|
||||
as *ctladdr.AddressSelector,
|
||||
sp storage.Prover,
|
||||
verif ffiwrapper.Verifier,
|
||||
ft sectorstorage.FaultTracker,
|
||||
|
Loading…
Reference in New Issue
Block a user