Improve gas price estimator

This commit is contained in:
Łukasz Magiera
2020-08-01 09:40:11 +02:00
parent 4e9343c487
commit e5ca4b22d5
4 changed files with 108 additions and 7 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ func (a *MpoolAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (ci
return a.Mpool.Push(smsg)
}
// GasMargin sets by how much should gas limit be increased over test execution
// GasMargin sets by how much should gas used be increased over test execution
var GasMargin = 1.5
func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*types.SignedMessage, error) {
@@ -97,7 +97,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t
if msg.GasLimit == 0 {
gasLimit, err := a.GasEstimateGasLimit(ctx, msg, types.TipSetKey{})
if err != nil {
return nil, xerrors.Errorf("estimating gas limit: %w", err)
return nil, xerrors.Errorf("estimating gas used: %w", err)
}
msg.GasLimit = int64(float64(gasLimit) * GasMargin)
}