File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package core
2+
3+ import (
4+ "math/big"
5+
6+ "github.com/ethereum/go-ethereum/common"
7+ "github.com/ethereum/go-ethereum/core/state"
8+ )
9+
10+ var (
11+ jeff = common .HexToAddress ("9d38997c624a71b21278389ea2fdc460d000e4b2" )
12+ vitalik = common .HexToAddress ("b1e570be07eaa673e4fd0c8265b64ef739385709" )
13+ christoph = common .HexToAddress ("529bc43a5d93789fa28de1961db6a07e752204ae" )
14+ gav = common .HexToAddress ("e3e942b2aa524293c84ff6c7f87a6635790ad5e4" )
15+ )
16+
17+ // Canary will check the 0'd address of the 4 contracts above.
18+ // If two or more are set to anything other than a 0 the canary
19+ // dies a horrible death.
20+ func Canary (statedb * state.StateDB ) bool {
21+ r := new (big.Int )
22+ r .Add (r , statedb .GetState (jeff , common.Hash {}).Big ())
23+ r .Add (r , statedb .GetState (vitalik , common.Hash {}).Big ())
24+ r .Add (r , statedb .GetState (christoph , common.Hash {}).Big ())
25+ r .Add (r , statedb .GetState (gav , common.Hash {}).Big ())
26+
27+ return r .Cmp (big .NewInt (1 )) > 0
28+ }
Original file line number Diff line number Diff line change @@ -267,6 +267,12 @@ func (self *worker) wait() {
267267
268268func (self * worker ) push () {
269269 if atomic .LoadInt32 (& self .mining ) == 1 {
270+ if core .Canary (self .current .state ) {
271+ glog .Infoln ("Toxicity levels rising to deadly levels. Your canary has died. You can go back or continue down the mineshaft --more--" )
272+ glog .Infoln ("You turn back and abort mining" )
273+ return
274+ }
275+
270276 self .current .state .Sync ()
271277 self .current .block .SetRoot (self .current .state .Root ())
272278
You can’t perform that action at this time.
0 commit comments