lotus/chain/vm/burn.go
Jakub Sztandera 5405a5adc3
Sepearate ComputeGasOutputs into sepearate function, add tests
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-08-05 02:10:25 +02:00

19 lines
458 B
Go

package vm
const (
gasOveruseNum = 3
gasOveruseDenom = 10
)
// ComputeGasOutputs computes amount of gas to be refunded and amount of gas to be burned
// Result is (refund, burn)
func ComputeGasOutputs(gasUsed, gasLimit int64) (int64, int64) {
allowedGasOverUsed := gasUsed + (gasUsed*gasOveruseNum)/gasOveruseDenom
gasToBurn := gasLimit - allowedGasOverUsed
if gasToBurn < 0 {
gasToBurn = 0
}
return gasLimit - gasUsed - gasToBurn, gasToBurn
}