diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-30 08:22:19 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-30 08:22:19 +0800 |
commit | 7625b07dd9a2a7b5c5a504c1276eea04596ac871 (patch) | |
tree | ce2a757cd4e0591fc15815b2dfae528ae517d36e /core/canary.go | |
parent | 72e2613a9fe3205fa5a67b72b832e03b2357ee88 (diff) | |
parent | 8f504063f465e0ca10c6bb53ee914d10a3d45c86 (diff) | |
download | go-tangerine-0.9.34.tar go-tangerine-0.9.34.tar.gz go-tangerine-0.9.34.tar.bz2 go-tangerine-0.9.34.tar.lz go-tangerine-0.9.34.tar.xz go-tangerine-0.9.34.tar.zst go-tangerine-0.9.34.zip |
Merge branch 'release/0.9.34'v0.9.34
Diffstat (limited to 'core/canary.go')
-rw-r--r-- | core/canary.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/canary.go b/core/canary.go new file mode 100644 index 000000000..de77c4bba --- /dev/null +++ b/core/canary.go @@ -0,0 +1,28 @@ +package core + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" +) + +var ( + jeff = common.HexToAddress("9d38997c624a71b21278389ea2fdc460d000e4b2") + vitalik = common.HexToAddress("b1e570be07eaa673e4fd0c8265b64ef739385709") + christoph = common.HexToAddress("529bc43a5d93789fa28de1961db6a07e752204ae") + gav = common.HexToAddress("e3e942b2aa524293c84ff6c7f87a6635790ad5e4") +) + +// Canary will check the 0'd address of the 4 contracts above. +// If two or more are set to anything other than a 0 the canary +// dies a horrible death. +func Canary(statedb *state.StateDB) bool { + r := new(big.Int) + r.Add(r, statedb.GetState(jeff, common.Hash{}).Big()) + r.Add(r, statedb.GetState(vitalik, common.Hash{}).Big()) + r.Add(r, statedb.GetState(christoph, common.Hash{}).Big()) + r.Add(r, statedb.GetState(gav, common.Hash{}).Big()) + + return r.Cmp(big.NewInt(1)) > 0 +} |