diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 54dcfe54c..f83e74118 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -15,6 +15,8 @@ import ( "runtime/pprof" "strings" + "github.com/filecoin-project/lotus/node/impl/full" + "github.com/filecoin-project/lotus/chain/types" paramfetch "github.com/filecoin-project/go-paramfetch" @@ -259,6 +261,7 @@ var DaemonCmd = &cli.Command{ liteMode = node.Options( node.Override(new(api.GatewayAPI), gapi), node.Override(new(stmgr.StateManagerAPI), modules.NewRPCStateManager), + node.Override(new(full.PushMessageAPI), modules.NewRPCPushMessageAPI), node.Unset(node.RunHelloKey), node.Unset(node.RunChainExchangeKey), node.Unset(node.RunPeerMgrKey), diff --git a/node/builder.go b/node/builder.go index 50a20d4bb..8579131b9 100644 --- a/node/builder.go +++ b/node/builder.go @@ -6,6 +6,8 @@ import ( "os" "time" + "github.com/filecoin-project/lotus/node/impl/full" + logging "github.com/ipfs/go-log" ci "github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/host" @@ -262,6 +264,7 @@ func Online() Option { Override(new(stmgr.UpgradeSchedule), stmgr.DefaultUpgradeSchedule()), Override(new(*stmgr.StateManager), stmgr.NewStateManagerWithUpgradeSchedule), Override(new(stmgr.StateManagerAPI), From(new(*stmgr.StateManager))), + Override(new(full.PushMessageAPI), From(new(full.MpoolAPI))), Override(new(*wallet.Wallet), wallet.NewWallet), Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner), diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index 1f093606c..000891bb2 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -15,11 +15,16 @@ import ( "github.com/filecoin-project/lotus/node/modules/dtypes" ) +type PushMessageAPI interface { + MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) +} + type MpoolAPI struct { fx.In WalletAPI GasAPI + PushMessageAPI MessageSigner *messagesigner.MessageSigner @@ -107,7 +112,7 @@ func (a *MpoolAPI) MpoolClear(ctx context.Context, local bool) error { } func (a *MpoolAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) { - return a.Mpool.Push(smsg) + return a.PushMessageAPI.MpoolPush(ctx, smsg) } func (a *MpoolAPI) MpoolPushUntrusted(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) { diff --git a/node/modules/pushmessage.go b/node/modules/pushmessage.go new file mode 100644 index 000000000..59af435a7 --- /dev/null +++ b/node/modules/pushmessage.go @@ -0,0 +1,25 @@ +package modules + +import ( + "context" + + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/node/impl/full" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/types" +) + +type RPCPushMessageAPI struct { + gapi api.GatewayAPI +} + +func NewRPCPushMessageAPI(api api.GatewayAPI) *RPCPushMessageAPI { + return &RPCPushMessageAPI{gapi: api} +} + +func (p *RPCPushMessageAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) { + return p.gapi.MpoolPush(ctx, smsg) +} + +var _ full.PushMessageAPI = (*RPCPushMessageAPI)(nil)