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
578b63e2
Commit
578b63e2
authored
Jan 13, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some miner reports
parent
7ade1778
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
6 deletions
+13
-6
block_manager.go
block_manager.go
+1
-0
dagger.go
dagger.go
+5
-2
ethereum.go
ethereum.go
+2
-2
peer.go
peer.go
+3
-0
server.go
server.go
+2
-2
No files found.
block_manager.go
View file @
578b63e2
...
...
@@ -154,6 +154,7 @@ func (bm *BlockManager) ValidateBlock(block *ethutil.Block) error {
// Verify the nonce of the block. Return an error if it's not valid
if
bm
.
bc
.
LastBlock
!=
nil
&&
block
.
PrevHash
==
""
&&
!
DaggerVerify
(
ethutil
.
BigD
(
block
.
Hash
()),
block
.
Difficulty
,
block
.
Nonce
)
{
return
errors
.
New
(
"Block's nonce is invalid"
)
}
...
...
dagger.go
View file @
578b63e2
...
...
@@ -7,6 +7,7 @@ import (
"math/big"
"math/rand"
"time"
"log"
)
type
Dagger
struct
{
...
...
@@ -22,7 +23,9 @@ func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
for
i
:=
0
;
i
<
1000
;
i
++
{
rnd
:=
r
.
Int63
()
if
dag
.
Eval
(
big
.
NewInt
(
rnd
))
.
Cmp
(
obj
)
<
0
{
res
:=
dag
.
Eval
(
big
.
NewInt
(
rnd
))
log
.
Printf
(
"rnd %v
\n
res %v
\n
obj %v
\n
"
,
rnd
,
res
,
obj
)
if
res
.
Cmp
(
obj
)
<
0
{
// Post back result on the channel
resChan
<-
rnd
// Notify other threads we've found a valid nonce
...
...
@@ -119,7 +122,7 @@ func Sum(sha hash.Hash) []byte {
func
(
dag
*
Dagger
)
Eval
(
N
*
big
.
Int
)
*
big
.
Int
{
pow
:=
ethutil
.
BigPow
(
2
,
26
)
dag
.
xn
=
N
.
Div
(
N
,
pow
)
dag
.
xn
=
pow
.
Div
(
N
,
pow
)
sha
:=
sha3
.
NewKeccak256
()
sha
.
Reset
()
...
...
ethereum.go
View file @
578b63e2
...
...
@@ -64,8 +64,8 @@ func main() {
go
func
()
{
for
{
res
:=
dagger
.
Search
(
ethutil
.
Big
(
"0
"
),
ethutil
.
BigPow
(
2
,
3
6
))
server
.
Broadcast
(
"block"
,
ethutil
.
Encode
(
res
.
String
()))
res
:=
dagger
.
Search
(
ethutil
.
Big
(
"0
1001"
),
ethutil
.
BigPow
(
2
,
2
6
))
server
.
Broadcast
(
"block
mine
"
,
ethutil
.
Encode
(
res
.
String
()))
}
}()
}
...
...
peer.go
View file @
578b63e2
...
...
@@ -162,6 +162,9 @@ out:
if
err
!=
nil
{
log
.
Println
(
err
)
}
case
"blockmine"
:
d
,
_
:=
ethutil
.
Decode
(
msg
.
Data
,
0
)
log
.
Printf
(
"block mined %s
\n
"
,
d
)
}
}
...
...
server.go
View file @
578b63e2
...
...
@@ -138,15 +138,15 @@ func (s *Server) Start() {
}()
// TMP
/*
go func() {
//time.Sleep(500 * time.Millisecond)
for {
s.Broadcast("block", s.blockManager.bc.GenesisBlock().MarshalRlp())
time.Sleep(1000 * time.Millisecond)
}
}()
*/
}
func
(
s
*
Server
)
Stop
()
{
...
...
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