feat: gateway - MpoolPush

This commit is contained in:
Dirk McCormick 2020-09-30 17:59:18 +02:00
parent 00a14de094
commit 8fa4c0a970
4 changed files with 37 additions and 1 deletions

View File

@ -15,6 +15,8 @@ import (
"runtime/pprof" "runtime/pprof"
"strings" "strings"
"github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
paramfetch "github.com/filecoin-project/go-paramfetch" paramfetch "github.com/filecoin-project/go-paramfetch"
@ -259,6 +261,7 @@ var DaemonCmd = &cli.Command{
liteMode = node.Options( liteMode = node.Options(
node.Override(new(api.GatewayAPI), gapi), node.Override(new(api.GatewayAPI), gapi),
node.Override(new(stmgr.StateManagerAPI), modules.NewRPCStateManager), node.Override(new(stmgr.StateManagerAPI), modules.NewRPCStateManager),
node.Override(new(full.PushMessageAPI), modules.NewRPCPushMessageAPI),
node.Unset(node.RunHelloKey), node.Unset(node.RunHelloKey),
node.Unset(node.RunChainExchangeKey), node.Unset(node.RunChainExchangeKey),
node.Unset(node.RunPeerMgrKey), node.Unset(node.RunPeerMgrKey),

View File

@ -6,6 +6,8 @@ import (
"os" "os"
"time" "time"
"github.com/filecoin-project/lotus/node/impl/full"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
ci "github.com/libp2p/go-libp2p-core/crypto" ci "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/host"
@ -262,6 +264,7 @@ func Online() Option {
Override(new(stmgr.UpgradeSchedule), stmgr.DefaultUpgradeSchedule()), Override(new(stmgr.UpgradeSchedule), stmgr.DefaultUpgradeSchedule()),
Override(new(*stmgr.StateManager), stmgr.NewStateManagerWithUpgradeSchedule), Override(new(*stmgr.StateManager), stmgr.NewStateManagerWithUpgradeSchedule),
Override(new(stmgr.StateManagerAPI), From(new(*stmgr.StateManager))), Override(new(stmgr.StateManagerAPI), From(new(*stmgr.StateManager))),
Override(new(full.PushMessageAPI), From(new(full.MpoolAPI))),
Override(new(*wallet.Wallet), wallet.NewWallet), Override(new(*wallet.Wallet), wallet.NewWallet),
Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner), Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner),

View File

@ -15,11 +15,16 @@ import (
"github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/dtypes"
) )
type PushMessageAPI interface {
MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error)
}
type MpoolAPI struct { type MpoolAPI struct {
fx.In fx.In
WalletAPI WalletAPI
GasAPI GasAPI
PushMessageAPI
MessageSigner *messagesigner.MessageSigner 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) { 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) { func (a *MpoolAPI) MpoolPushUntrusted(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) {

View File

@ -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)