From c4251912dd8fb95f4f773c1625d062dd02b15f0e Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 7 Aug 2020 17:45:31 +0300 Subject: [PATCH] mpool config api --- api/api_full.go | 5 +++++ api/apistruct/struct.go | 10 ++++++++++ node/impl/full/mpool.go | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/api/api_full.go b/api/api_full.go index a6a5f79e8..515e57c0f 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -173,6 +173,11 @@ type FullNode interface { MpoolGetNonce(context.Context, address.Address) (uint64, error) MpoolSub(context.Context) (<-chan MpoolUpdate, error) + // MpoolGetConfig returns (a copy of) the current mpool config + MpoolGetConfig(context.Context) (*types.MpoolConfig, error) + // MpoolSetConfig sets the mpool config to (a copy of) the supplied config + MpoolSetConfig(context.Context, *types.MpoolConfig) error + // MethodGroup: Miner MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*MiningBaseInfo, error) diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index a780c87d4..f53b91f2f 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -97,6 +97,8 @@ type FullNodeStruct struct { SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"` SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"` + MpoolGetConfig func(context.Context) (*types.MpoolConfig, error) `perm:"read"` + MpoolSetConfig func(context.Context, *types.MpoolConfig) error `perm:"write"` MpoolSelect func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"` MpoolPending func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"` MpoolPush func(context.Context, *types.SignedMessage) (cid.Cid, error) `perm:"write"` @@ -445,6 +447,14 @@ func (c *FullNodeStruct) GasEstimateGasLimit(ctx context.Context, msg *types.Mes return c.Internal.GasEstimateGasLimit(ctx, msg, tsk) } +func (c *FullNodeStruct) MpoolGetConfig(ctx context.Context) (*types.MpoolConfig, error) { + return c.Internal.MpoolGetConfig(ctx) +} + +func (c *FullNodeStruct) MpoolSetConfig(ctx context.Context, cfg *types.MpoolConfig) error { + return c.Internal.MpoolSetConfig(ctx, cfg) +} + func (c *FullNodeStruct) MpoolSelect(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) { return c.Internal.MpoolSelect(ctx, tsk) } diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index d1976b1e9..01a8b9055 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -25,6 +25,15 @@ type MpoolAPI struct { Mpool *messagepool.MessagePool } +func (a *MpoolAPI) MpoolGetConfig(context.Context) (*types.MpoolConfig, error) { + return a.Mpool.GetConfig(), nil +} + +func (a *MpoolAPI) MpoolSetConfig(ctx context.Context, cfg *types.MpoolConfig) error { + a.Mpool.SetConfig(cfg) + return nil +} + func (a *MpoolAPI) MpoolSelect(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) { ts, err := a.Chain.GetTipSetFromKey(tsk) if err != nil {