diff options
Diffstat (limited to 'libevmasm/GasMeter.cpp')
-rw-r--r-- | libevmasm/GasMeter.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index caa06fc0..3554f809 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -258,4 +258,16 @@ unsigned GasMeter::runGas(Instruction _instruction) return 0; } - +u256 GasMeter::dataGas(bytes const& _data, bool _inCreation) +{ + bigint gas = 0; + if (_inCreation) + { + for (auto b: _data) + gas += (b != 0) ? GasCosts::txDataNonZeroGas : GasCosts::txDataZeroGas; + } + else + gas = bigint(GasCosts::createDataGas) * _data.size(); + assertThrow(gas < bigint(u256(-1)), OptimizerException, "Gas cost exceeds 256 bits."); + return u256(gas); +} |