-
Notifications
You must be signed in to change notification settings - Fork 210
/
gas.go
35 lines (30 loc) · 943 Bytes
/
gas.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package multisig
import (
"math"
"github.com/spacemeshos/go-spacemesh/genvm/core"
)
func BaseGas(method uint8, signatures int) uint64 {
switch method {
case core.MethodSpawn:
return core.TX + core.EDVERIFY*uint64(signatures) + core.SPAWN
case core.MethodSpend:
return core.TX + core.EDVERIFY*uint64(signatures)
}
return math.MaxUint64
}
func LoadGas(keys int) uint64 {
return core.ACCOUNT_ACCESS + core.SizeGas(core.LOAD, core.PUBLIC_KEY_SIZE*keys+core.ACCOUNT_HEADER_SIZE)
}
func ExecGas(method uint8, keys int) uint64 {
switch method {
case core.MethodSpawn:
return core.SizeGas(core.STORE, core.PUBLIC_KEY_SIZE*keys+core.ACCOUNT_HEADER_SIZE)
case core.MethodSpend:
gas := core.ACCOUNT_ACCESS
gas += core.SizeGas(core.LOAD, core.ACCOUNT_BALANCE_SIZE)
gas += core.SizeGas(core.UPDATE, core.ACCOUNT_HEADER_SIZE)
gas += core.SizeGas(core.UPDATE, core.ACCOUNT_BALANCE_SIZE)
return gas
}
return math.MaxUint64
}