From 1d5059c28196bf6dddd2a0fdafdaf02552d9d2cf Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 22 Apr 2020 15:37:59 -0700 Subject: [PATCH] add tipsetkey to estimate gas api --- api/api_full.go | 2 +- api/apistruct/struct.go | 16 ++++++++-------- chain/messagepool/messagepool.go | 2 +- node/impl/full/mpool.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index d641b53db..2cba47cb1 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -66,7 +66,7 @@ type FullNode interface { MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error) // get nonce, sign, push MpoolGetNonce(context.Context, address.Address) (uint64, error) MpoolSub(context.Context) (<-chan MpoolUpdate, error) - MpoolEstimateGasPrice(context.Context, uint64, address.Address, int64) (types.BigInt, error) + MpoolEstimateGasPrice(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error) // FullNodeStruct diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 733afc68e..c5ff89d69 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -81,12 +81,12 @@ 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"` - MpoolPending func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"` - MpoolPush func(context.Context, *types.SignedMessage) (cid.Cid, error) `perm:"write"` - MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"` - MpoolGetNonce func(context.Context, address.Address) (uint64, error) `perm:"read"` - MpoolSub func(context.Context) (<-chan api.MpoolUpdate, error) `perm:"read"` - MpoolEstimateGasPrice func(context.Context, uint64, address.Address, int64) (types.BigInt, 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"` + MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"` + MpoolGetNonce func(context.Context, address.Address) (uint64, error) `perm:"read"` + MpoolSub func(context.Context) (<-chan api.MpoolUpdate, error) `perm:"read"` + MpoolEstimateGasPrice func(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error) `perm:"read"` MinerGetBaseInfo func(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*api.MiningBaseInfo, error) `perm:"read"` MinerCreateBlock func(context.Context, *api.BlockTemplate) (*types.BlockMsg, error) `perm:"write"` @@ -333,8 +333,8 @@ func (c *FullNodeStruct) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate, return c.Internal.MpoolSub(ctx) } -func (c *FullNodeStruct) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64) (types.BigInt, error) { - return c.Internal.MpoolEstimateGasPrice(ctx, nblocksincl, sender, limit) +func (c *FullNodeStruct) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64, tsk types.TipSetKey) (types.BigInt, error) { + return c.Internal.MpoolEstimateGasPrice(ctx, nblocksincl, sender, limit, tsk) } func (c *FullNodeStruct) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) { diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 70226a579..96f8e0232 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -825,7 +825,7 @@ func (mp *MessagePool) loadLocal() error { const MinGasPrice = 0 -func (mp *MessagePool) EstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64) (types.BigInt, error) { +func (mp *MessagePool) EstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) { // TODO: something smarter obviously switch nblocksincl { case 0: diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index b5a6fb954..79e6d30be 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -119,6 +119,6 @@ func (a *MpoolAPI) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate, error) return a.Mpool.Updates(ctx) } -func (a *MpoolAPI) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64) (types.BigInt, error) { - return a.Mpool.EstimateGasPrice(ctx, nblocksincl, sender, gaslimit) +func (a *MpoolAPI) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) { + return a.Mpool.EstimateGasPrice(ctx, nblocksincl, sender, gaslimit, tsk) }