Skip to content

Commit

Permalink
check valid condition in consumeSeekGas
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 committed Sep 23, 2021
1 parent 97651eb commit 0d13008
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions store/gaskv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ func (gi *gasIterator) Error() error {
// consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost
// based on the current value's length.
func (gi *gasIterator) consumeSeekGas() {
value := gi.Value()
if gi.Valid() {
value := gi.Value()

gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc)
gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc)
gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc)
gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc)

}
}

0 comments on commit 0d13008

Please sign in to comment.