more expressive estimate gas api

This commit is contained in:
Jeromy 2020-04-22 11:03:58 -07:00
parent 2a97045317
commit 7e7caa8859
4 changed files with 13 additions and 13 deletions

View File

@ -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) (types.BigInt, error)
MpoolEstimateGasPrice(context.Context, uint64, address.Address, int64) (types.BigInt, error)
// FullNodeStruct

View File

@ -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) (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.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, priority uint64) (types.BigInt, error) {
return c.Internal.MpoolEstimateGasPrice(ctx, priority)
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) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) {

View File

@ -825,9 +825,9 @@ func (mp *MessagePool) loadLocal() error {
const MinGasPrice = 0
func (mp *MessagePool) EstimateGasPrice(ctx context.Context, priority uint64) (types.BigInt, error) {
func (mp *MessagePool) EstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64) (types.BigInt, error) {
// TODO: something smarter obviously
switch priority {
switch nblocksincl {
case 0:
return types.NewInt(MinGasPrice + 2), nil
case 1:

View File

@ -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, priority uint64) (types.BigInt, error) {
return a.Mpool.EstimateGasPrice(ctx, priority)
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)
}