-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A.5.1. Addition, subtraction, multiplication.
Signed-off-by: andreypfau <[email protected]>
- Loading branch information
1 parent
bce1d87
commit a9e02f9
Showing
13 changed files
with
322 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,48 @@ | ||
package org.ton.kotlin.tvm | ||
|
||
import org.ton.cell.Cell | ||
import kotlin.math.max | ||
|
||
public interface GasCalculator { | ||
public fun calculateOperationCost(bitCount: Int): Long | ||
|
||
public fun calculateRollCost(elements: Int): Long = max(elements - 255L, 0L) | ||
|
||
public fun calculateCellLoad(cell: Cell): Long | ||
|
||
public fun calculateCellReload(cell: Cell): Long | ||
|
||
public fun calculateCellCreate(cell: Cell): Long | ||
|
||
public fun calculateException(): Long | ||
|
||
public fun calculateImplicitReturn(): Long | ||
} | ||
|
||
public object FreeGasCalculator : GasCalculator { | ||
override fun calculateOperationCost(bitCount: Int): Long = 0 | ||
|
||
override fun calculateCellLoad(cell: Cell): Long = 0 | ||
|
||
override fun calculateCellReload(cell: Cell): Long = 0 | ||
|
||
override fun calculateCellCreate(cell: Cell): Long = 0 | ||
|
||
override fun calculateException(): Long = 0 | ||
|
||
override fun calculateImplicitReturn(): Long = 0 | ||
} | ||
|
||
public object DefaultGasCalculator : GasCalculator { | ||
override fun calculateOperationCost(bitCount: Int): Long = 10 + bitCount.toLong() | ||
|
||
override fun calculateCellLoad(cell: Cell): Long = 100 | ||
|
||
override fun calculateCellReload(cell: Cell): Long = 25 | ||
|
||
override fun calculateCellCreate(cell: Cell): Long = 500 | ||
|
||
override fun calculateException(): Long = 50 | ||
|
||
override fun calculateImplicitReturn(): Long = 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.