canary.go 922 B

12345678910111213141516171819202122232425262728
  1. package core
  2. import (
  3. "math/big"
  4. "github.com/ethereum/go-ethereum/common"
  5. "github.com/ethereum/go-ethereum/core/state"
  6. )
  7. var (
  8. jeff = common.HexToAddress("a8edb1ac2c86d3d9d78f96cd18001f60df29e52c")
  9. vitalik = common.HexToAddress("1baf27b88c48dd02b744999cf3522766929d2b2a")
  10. christoph = common.HexToAddress("60d11b58744784dc97f878f7e3749c0f1381a004")
  11. gav = common.HexToAddress("4bb7e8ae99b645c2b7860b8f3a2328aae28bd80a")
  12. )
  13. // Canary will check the 0'd address of the 4 contracts above.
  14. // If two or more are set to anything other than a 0 the canary
  15. // dies a horrible death.
  16. func Canary(statedb *state.StateDB) bool {
  17. r := new(big.Int)
  18. r.Add(r, statedb.GetState(jeff, common.Hash{}).Big())
  19. r.Add(r, statedb.GetState(vitalik, common.Hash{}).Big())
  20. r.Add(r, statedb.GetState(christoph, common.Hash{}).Big())
  21. r.Add(r, statedb.GetState(gav, common.Hash{}).Big())
  22. return r.Cmp(big.NewInt(1)) > 0
  23. }