aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVitalik Buterin <v@buterin.com>2015-07-02 18:36:32 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-20 22:28:28 +0800
commit8160b8618d788802e943fbf6c8ef8bbf98501807 (patch)
tree0cd582f4a559fc842aa68d052c37bf3bd08fbb17 /core
parent02c5022742e2bf6d2aadca06a6a1655214ba9d55 (diff)
downloaddexon-8160b8618d788802e943fbf6c8ef8bbf98501807.tar
dexon-8160b8618d788802e943fbf6c8ef8bbf98501807.tar.gz
dexon-8160b8618d788802e943fbf6c8ef8bbf98501807.tar.bz2
dexon-8160b8618d788802e943fbf6c8ef8bbf98501807.tar.lz
dexon-8160b8618d788802e943fbf6c8ef8bbf98501807.tar.xz
dexon-8160b8618d788802e943fbf6c8ef8bbf98501807.tar.zst
dexon-8160b8618d788802e943fbf6c8ef8bbf98501807.zip
Fixed canary to require 2+ nonzero, not sum 2+
Diffstat (limited to 'core')
-rw-r--r--core/canary.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/core/canary.go b/core/canary.go
index 710e31530..b69621a6a 100644
--- a/core/canary.go
+++ b/core/canary.go
@@ -34,11 +34,18 @@ var (
// 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
+ var r int
+ if (statedb.GetState(jeff, common.Hash{}).Big().Cmp(big.NewInt(0)) > 0) {
+ r++
+ }
+ if (statedb.GetState(gav, common.Hash{}).Big().Cmp(big.NewInt(0)) > 0) {
+ r++
+ }
+ if (statedb.GetState(christoph, common.Hash{}).Big().Cmp(big.NewInt(0)) > 0) {
+ r++
+ }
+ if (statedb.GetState(vitalik, common.Hash{}).Big().Cmp(big.NewInt(0)) > 0) {
+ r++
+ }
+ return r > 1
}