Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
b39042db
Commit
b39042db
authored
Jun 29, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, miner: implemented canary
parent
d1e93db3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
canary.go
core/canary.go
+28
-0
worker.go
miner/worker.go
+6
-0
No files found.
core/canary.go
0 → 100644
View file @
b39042db
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
}
miner/worker.go
View file @
b39042db
...
@@ -267,6 +267,12 @@ func (self *worker) wait() {
...
@@ -267,6 +267,12 @@ func (self *worker) wait() {
func
(
self
*
worker
)
push
()
{
func
(
self
*
worker
)
push
()
{
if
atomic
.
LoadInt32
(
&
self
.
mining
)
==
1
{
if
atomic
.
LoadInt32
(
&
self
.
mining
)
==
1
{
if
core
.
Canary
(
self
.
current
.
state
)
{
glog
.
Infoln
(
"Toxicity levels rising to deadly levels. Your canary has died. You can go back or continue down the mineshaft --more--"
)
glog
.
Infoln
(
"You turn back and abort mining"
)
return
}
self
.
current
.
state
.
Sync
()
self
.
current
.
state
.
Sync
()
self
.
current
.
block
.
SetRoot
(
self
.
current
.
state
.
Root
())
self
.
current
.
block
.
SetRoot
(
self
.
current
.
state
.
Root
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment