aboutsummaryrefslogtreecommitdiffstats
path: root/vm/address.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2014-12-22 02:06:24 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2014-12-22 02:06:24 +0800
commitbab78bbeb691d95bdd0222435af0c11cb3485a79 (patch)
tree804c9689546ce362a2862b00bb4e76160052f5d6 /vm/address.go
parent7a79428278412ab1f73708af51bce063b000b7a7 (diff)
parent1360f027d9e365242466ca346b2b56f421729d91 (diff)
downloadgo-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.tar
go-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.tar.gz
go-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.tar.bz2
go-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.tar.lz
go-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.tar.xz
go-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.tar.zst
go-tangerine-bab78bbeb691d95bdd0222435af0c11cb3485a79.zip
Merge branch 'tests' of github.com:ethereum/go-ethereum into tests
Diffstat (limited to 'vm/address.go')
-rw-r--r--vm/address.go24
1 files changed, 17 insertions, 7 deletions
diff --git a/vm/address.go b/vm/address.go
index 06bd35f6b..611979c94 100644
--- a/vm/address.go
+++ b/vm/address.go
@@ -11,19 +11,29 @@ type Address interface {
Call(in []byte) []byte
}
-type PrecompiledAddress struct {
- Gas *big.Int
+type PrecompiledAccount struct {
+ Gas func(l int) *big.Int
fn func(in []byte) []byte
}
-func (self PrecompiledAddress) Call(in []byte) []byte {
+func (self PrecompiledAccount) Call(in []byte) []byte {
return self.fn(in)
}
-var Precompiled = map[uint64]*PrecompiledAddress{
- 1: &PrecompiledAddress{big.NewInt(500), ecrecoverFunc},
- 2: &PrecompiledAddress{big.NewInt(100), sha256Func},
- 3: &PrecompiledAddress{big.NewInt(100), ripemd160Func},
+var Precompiled = map[string]*PrecompiledAccount{
+ string(ethutil.LeftPadBytes([]byte{1}, 20)): &PrecompiledAccount{func(l int) *big.Int {
+ return GasEcrecover
+ }, ecrecoverFunc},
+ string(ethutil.LeftPadBytes([]byte{2}, 20)): &PrecompiledAccount{func(l int) *big.Int {
+ n := big.NewInt(int64(l+31)/32 + 1)
+ n.Mul(n, GasSha256)
+ return n
+ }, sha256Func},
+ string(ethutil.LeftPadBytes([]byte{3}, 20)): &PrecompiledAccount{func(l int) *big.Int {
+ n := big.NewInt(int64(l+31)/32 + 1)
+ n.Mul(n, GasRipemd)
+ return n
+ }, ripemd160Func},
}
func sha256Func(in []byte) []byte {