fix paychmgr constructor to take an easier to implement interface
This commit is contained in:
parent
e0b650d4ec
commit
cbc7f1c244
@ -308,6 +308,7 @@ var ChainNode = Options(
|
|||||||
Override(new(api.WalletAPI), From(new(wallet.MultiWallet))),
|
Override(new(api.WalletAPI), From(new(wallet.MultiWallet))),
|
||||||
|
|
||||||
// Service: Payment channels
|
// Service: Payment channels
|
||||||
|
Override(new(paychmgr.PaychAPI), new(modules.PaychAPI)),
|
||||||
Override(new(*paychmgr.Store), modules.NewPaychStore),
|
Override(new(*paychmgr.Store), modules.NewPaychStore),
|
||||||
Override(new(*paychmgr.Manager), modules.NewManager),
|
Override(new(*paychmgr.Manager), modules.NewManager),
|
||||||
Override(HandlePaymentChannelManagerKey, modules.HandlePaychManager),
|
Override(HandlePaymentChannelManagerKey, modules.HandlePaychManager),
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
|
"github.com/filecoin-project/lotus/node/impl/full"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||||
"github.com/filecoin-project/lotus/paychmgr"
|
"github.com/filecoin-project/lotus/paychmgr"
|
||||||
@ -24,6 +25,13 @@ func NewPaychStore(ds dtypes.MetadataDS) *paychmgr.Store {
|
|||||||
return paychmgr.NewStore(ds)
|
return paychmgr.NewStore(ds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PaychAPI struct {
|
||||||
|
fx.In
|
||||||
|
|
||||||
|
full.MpoolAPI
|
||||||
|
full.StateAPI
|
||||||
|
}
|
||||||
|
|
||||||
// HandlePaychManager is called by dependency injection to set up hooks
|
// HandlePaychManager is called by dependency injection to set up hooks
|
||||||
func HandlePaychManager(lc fx.Lifecycle, pm *paychmgr.Manager) {
|
func HandlePaychManager(lc fx.Lifecycle, pm *paychmgr.Manager) {
|
||||||
lc.Append(fx.Hook{
|
lc.Append(fx.Hook{
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"go.uber.org/fx"
|
|
||||||
xerrors "golang.org/x/xerrors"
|
xerrors "golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -19,21 +18,12 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node/impl/full"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("paych")
|
var log = logging.Logger("paych")
|
||||||
|
|
||||||
var errProofNotSupported = errors.New("payment channel proof parameter is not supported")
|
var errProofNotSupported = errors.New("payment channel proof parameter is not supported")
|
||||||
|
|
||||||
// PaychAPI is used by dependency injection to pass the consituent APIs to NewManager()
|
|
||||||
type PaychAPI struct {
|
|
||||||
fx.In
|
|
||||||
|
|
||||||
full.MpoolAPI
|
|
||||||
full.StateAPI
|
|
||||||
}
|
|
||||||
|
|
||||||
// stateManagerAPI defines the methods needed from StateManager
|
// stateManagerAPI defines the methods needed from StateManager
|
||||||
type stateManagerAPI interface {
|
type stateManagerAPI interface {
|
||||||
ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
|
ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
|
||||||
@ -42,7 +32,7 @@ type stateManagerAPI interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// paychAPI defines the API methods needed by the payment channel manager
|
// paychAPI defines the API methods needed by the payment channel manager
|
||||||
type paychAPI interface {
|
type PaychAPI interface {
|
||||||
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
||||||
StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error)
|
StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error)
|
||||||
MpoolPushMessage(ctx context.Context, msg *types.Message, maxFee *api.MessageSendSpec) (*types.SignedMessage, error)
|
MpoolPushMessage(ctx context.Context, msg *types.Message, maxFee *api.MessageSendSpec) (*types.SignedMessage, error)
|
||||||
@ -54,13 +44,13 @@ type paychAPI interface {
|
|||||||
// managerAPI defines all methods needed by the manager
|
// managerAPI defines all methods needed by the manager
|
||||||
type managerAPI interface {
|
type managerAPI interface {
|
||||||
stateManagerAPI
|
stateManagerAPI
|
||||||
paychAPI
|
PaychAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
// managerAPIImpl is used to create a composite that implements managerAPI
|
// managerAPIImpl is used to create a composite that implements managerAPI
|
||||||
type managerAPIImpl struct {
|
type managerAPIImpl struct {
|
||||||
stmgr.StateManagerAPI
|
stmgr.StateManagerAPI
|
||||||
paychAPI
|
PaychAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
@ -77,7 +67,7 @@ type Manager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewManager(ctx context.Context, shutdown func(), sm stmgr.StateManagerAPI, pchstore *Store, api PaychAPI) *Manager {
|
func NewManager(ctx context.Context, shutdown func(), sm stmgr.StateManagerAPI, pchstore *Store, api PaychAPI) *Manager {
|
||||||
impl := &managerAPIImpl{StateManagerAPI: sm, paychAPI: &api}
|
impl := &managerAPIImpl{StateManagerAPI: sm, PaychAPI: api}
|
||||||
return &Manager{
|
return &Manager{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
shutdown: shutdown,
|
shutdown: shutdown,
|
||||||
|
Loading…
Reference in New Issue
Block a user