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
b1cc9cdc
Commit
b1cc9cdc
authored
May 05, 2015
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate new ethash API and change geth makedag cmd
parent
50659f4b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
27 deletions
+41
-27
main.go
cmd/geth/main.go
+28
-6
flags.go
cmd/utils/flags.go
+1
-1
chain_makers.go
core/chain_makers.go
+2
-2
backend.go
eth/backend.go
+1
-2
agent.go
miner/agent.go
+1
-1
miner.go
miner/miner.go
+0
-7
dagger.go
pow/dagger/dagger.go
+3
-3
pow.go
pow/ezp/pow.go
+4
-4
pow.go
pow/pow.go
+1
-1
No files found.
cmd/geth/main.go
View file @
b1cc9cdc
...
@@ -27,8 +27,10 @@ import (
...
@@ -27,8 +27,10 @@ import (
"io/ioutil"
"io/ioutil"
"os"
"os"
"path"
"path"
"path/filepath"
"runtime"
"runtime"
"strconv"
"strconv"
"strings"
"time"
"time"
"github.com/codegangsta/cli"
"github.com/codegangsta/cli"
...
@@ -601,12 +603,32 @@ func dump(ctx *cli.Context) {
...
@@ -601,12 +603,32 @@ func dump(ctx *cli.Context) {
}
}
func
makedag
(
ctx
*
cli
.
Context
)
{
func
makedag
(
ctx
*
cli
.
Context
)
{
chain
,
_
,
_
:=
utils
.
GetChain
(
ctx
)
args
:=
ctx
.
Args
()
pow
:=
ethash
.
New
(
chain
)
wrongArgs
:=
func
()
{
fmt
.
Println
(
"making cache"
)
utils
.
Fatalf
(
`Usage: geth makedag <block number> <outputdir>`
)
pow
.
UpdateCache
(
0
,
true
)
}
fmt
.
Println
(
"making DAG"
)
switch
{
pow
.
UpdateDAG
()
case
len
(
args
)
==
2
:
blockNum
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
dir
:=
args
[
1
]
if
err
!=
nil
{
wrongArgs
()
}
else
{
dir
=
filepath
.
Clean
(
dir
)
// seems to require a trailing slash
if
!
strings
.
HasSuffix
(
dir
,
"/"
)
{
dir
=
dir
+
"/"
}
_
,
err
=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Can't find dir"
)
}
fmt
.
Println
(
"making DAG, this could take awhile..."
)
ethash
.
MakeDAG
(
blockNum
,
dir
)
}
default
:
wrongArgs
()
}
}
}
func
version
(
c
*
cli
.
Context
)
{
func
version
(
c
*
cli
.
Context
)
{
...
...
cmd/utils/flags.go
View file @
b1cc9cdc
...
@@ -316,7 +316,7 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Dat
...
@@ -316,7 +316,7 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Dat
eventMux
:=
new
(
event
.
TypeMux
)
eventMux
:=
new
(
event
.
TypeMux
)
chainManager
:=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eventMux
)
chainManager
:=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eventMux
)
pow
:=
ethash
.
New
(
chainManager
)
pow
:=
ethash
.
New
()
txPool
:=
core
.
NewTxPool
(
eventMux
,
chainManager
.
State
,
chainManager
.
GasLimit
)
txPool
:=
core
.
NewTxPool
(
eventMux
,
chainManager
.
State
,
chainManager
.
GasLimit
)
blockProcessor
:=
core
.
NewBlockProcessor
(
stateDb
,
extraDb
,
pow
,
txPool
,
chainManager
,
eventMux
)
blockProcessor
:=
core
.
NewBlockProcessor
(
stateDb
,
extraDb
,
pow
,
txPool
,
chainManager
,
eventMux
)
chainManager
.
SetProcessor
(
blockProcessor
)
chainManager
.
SetProcessor
(
blockProcessor
)
...
...
core/chain_makers.go
View file @
b1cc9cdc
...
@@ -14,8 +14,8 @@ import (
...
@@ -14,8 +14,8 @@ import (
// So we can generate blocks easily
// So we can generate blocks easily
type
FakePow
struct
{}
type
FakePow
struct
{}
func
(
f
FakePow
)
Search
(
block
pow
.
Block
,
stop
<-
chan
struct
{})
(
uint64
,
[]
byte
,
[]
byte
)
{
func
(
f
FakePow
)
Search
(
block
pow
.
Block
,
stop
<-
chan
struct
{})
(
uint64
,
[]
byte
)
{
return
0
,
nil
,
nil
return
0
,
nil
}
}
func
(
f
FakePow
)
Verify
(
block
pow
.
Block
)
bool
{
return
true
}
func
(
f
FakePow
)
Verify
(
block
pow
.
Block
)
bool
{
return
true
}
func
(
f
FakePow
)
GetHashrate
()
int64
{
return
0
}
func
(
f
FakePow
)
GetHashrate
()
int64
{
return
0
}
...
...
eth/backend.go
View file @
b1cc9cdc
...
@@ -220,7 +220,7 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -220,7 +220,7 @@ func New(config *Config) (*Ethereum, error) {
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
eth
.
downloader
=
downloader
.
New
(
eth
.
chainManager
.
HasBlock
,
eth
.
chainManager
.
GetBlock
)
eth
.
downloader
=
downloader
.
New
(
eth
.
chainManager
.
HasBlock
,
eth
.
chainManager
.
GetBlock
)
eth
.
pow
=
ethash
.
New
(
eth
.
chainManager
)
eth
.
pow
=
ethash
.
New
()
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
EventMux
(),
eth
.
chainManager
.
State
,
eth
.
chainManager
.
GasLimit
)
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
EventMux
(),
eth
.
chainManager
.
State
,
eth
.
chainManager
.
GasLimit
)
eth
.
blockProcessor
=
core
.
NewBlockProcessor
(
stateDb
,
extraDb
,
eth
.
pow
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
blockProcessor
=
core
.
NewBlockProcessor
(
stateDb
,
extraDb
,
eth
.
pow
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
...
@@ -318,7 +318,6 @@ func (s *Ethereum) PeersInfo() (peersinfo []*PeerInfo) {
...
@@ -318,7 +318,6 @@ func (s *Ethereum) PeersInfo() (peersinfo []*PeerInfo) {
func
(
s
*
Ethereum
)
ResetWithGenesisBlock
(
gb
*
types
.
Block
)
{
func
(
s
*
Ethereum
)
ResetWithGenesisBlock
(
gb
*
types
.
Block
)
{
s
.
chainManager
.
ResetWithGenesisBlock
(
gb
)
s
.
chainManager
.
ResetWithGenesisBlock
(
gb
)
s
.
pow
.
UpdateCache
(
0
,
true
)
}
}
func
(
s
*
Ethereum
)
StartMining
()
error
{
func
(
s
*
Ethereum
)
StartMining
()
error
{
...
...
miner/agent.go
View file @
b1cc9cdc
...
@@ -85,7 +85,7 @@ func (self *CpuMiner) mine(block *types.Block) {
...
@@ -85,7 +85,7 @@ func (self *CpuMiner) mine(block *types.Block) {
self
.
chMu
.
Unlock
()
self
.
chMu
.
Unlock
()
// Mine
// Mine
nonce
,
mixDigest
,
_
:=
self
.
pow
.
Search
(
block
,
self
.
quitCurrentOp
)
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
block
,
self
.
quitCurrentOp
)
if
nonce
!=
0
{
if
nonce
!=
0
{
block
.
SetNonce
(
nonce
)
block
.
SetNonce
(
nonce
)
block
.
Header
()
.
MixDigest
=
common
.
BytesToHash
(
mixDigest
)
block
.
Header
()
.
MixDigest
=
common
.
BytesToHash
(
mixDigest
)
...
...
miner/miner.go
View file @
b1cc9cdc
...
@@ -3,7 +3,6 @@ package miner
...
@@ -3,7 +3,6 @@ package miner
import
(
import
(
"math/big"
"math/big"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
...
@@ -41,13 +40,7 @@ func (self *Miner) Mining() bool {
...
@@ -41,13 +40,7 @@ func (self *Miner) Mining() bool {
func
(
self
*
Miner
)
Start
(
coinbase
common
.
Address
)
{
func
(
self
*
Miner
)
Start
(
coinbase
common
.
Address
)
{
self
.
mining
=
true
self
.
mining
=
true
self
.
worker
.
coinbase
=
coinbase
self
.
worker
.
coinbase
=
coinbase
if
self
.
threads
>
0
{
self
.
pow
.
(
*
ethash
.
Ethash
)
.
UpdateDAG
()
}
self
.
worker
.
start
()
self
.
worker
.
start
()
self
.
worker
.
commitNewWork
()
self
.
worker
.
commitNewWork
()
}
}
...
...
pow/dagger/dagger.go
View file @
b1cc9cdc
...
@@ -6,8 +6,8 @@ import (
...
@@ -6,8 +6,8 @@ import (
"math/rand"
"math/rand"
"time"
"time"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
)
)
...
@@ -44,7 +44,7 @@ func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
...
@@ -44,7 +44,7 @@ func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
resChan
<-
0
resChan
<-
0
}
}
func
(
dag
*
Dagger
)
Search
(
hash
,
diff
*
big
.
Int
)
(
[]
byte
,
[]
byte
,
[]
byte
)
{
func
(
dag
*
Dagger
)
Search
(
hash
,
diff
*
big
.
Int
)
(
uint64
,
[]
byte
)
{
// TODO fix multi threading. Somehow it results in the wrong nonce
// TODO fix multi threading. Somehow it results in the wrong nonce
amountOfRoutines
:=
1
amountOfRoutines
:=
1
...
@@ -69,7 +69,7 @@ func (dag *Dagger) Search(hash, diff *big.Int) ([]byte, []byte, []byte) {
...
@@ -69,7 +69,7 @@ func (dag *Dagger) Search(hash, diff *big.Int) ([]byte, []byte, []byte) {
}
}
}
}
return
big
.
NewInt
(
res
)
.
Bytes
(),
nil
,
nil
return
uint64
(
res
)
,
nil
}
}
func
(
dag
*
Dagger
)
Verify
(
hash
,
diff
,
nonce
*
big
.
Int
)
bool
{
func
(
dag
*
Dagger
)
Verify
(
hash
,
diff
,
nonce
*
big
.
Int
)
bool
{
...
...
pow/ezp/pow.go
View file @
b1cc9cdc
...
@@ -32,7 +32,7 @@ func (pow *EasyPow) Turbo(on bool) {
...
@@ -32,7 +32,7 @@ func (pow *EasyPow) Turbo(on bool) {
pow
.
turbo
=
on
pow
.
turbo
=
on
}
}
func
(
pow
*
EasyPow
)
Search
(
block
pow
.
Block
,
stop
<-
chan
struct
{})
(
uint64
,
[]
byte
,
[]
byte
)
{
func
(
pow
*
EasyPow
)
Search
(
block
pow
.
Block
,
stop
<-
chan
struct
{})
(
uint64
,
[]
byte
)
{
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
hash
:=
block
.
HashNoNonce
()
hash
:=
block
.
HashNoNonce
()
diff
:=
block
.
Difficulty
()
diff
:=
block
.
Difficulty
()
...
@@ -57,7 +57,7 @@ empty:
...
@@ -57,7 +57,7 @@ empty:
for
{
for
{
select
{
select
{
case
<-
stop
:
case
<-
stop
:
return
0
,
nil
,
nil
return
0
,
nil
default
:
default
:
i
++
i
++
...
@@ -67,7 +67,7 @@ empty:
...
@@ -67,7 +67,7 @@ empty:
sha
:=
uint64
(
r
.
Int63
())
sha
:=
uint64
(
r
.
Int63
())
if
verify
(
hash
,
diff
,
sha
)
{
if
verify
(
hash
,
diff
,
sha
)
{
return
sha
,
nil
,
nil
return
sha
,
nil
}
}
}
}
...
@@ -76,7 +76,7 @@ empty:
...
@@ -76,7 +76,7 @@ empty:
}
}
}
}
return
0
,
nil
,
nil
return
0
,
nil
}
}
func
(
pow
*
EasyPow
)
Verify
(
block
pow
.
Block
)
bool
{
func
(
pow
*
EasyPow
)
Verify
(
block
pow
.
Block
)
bool
{
...
...
pow/pow.go
View file @
b1cc9cdc
package
pow
package
pow
type
PoW
interface
{
type
PoW
interface
{
Search
(
block
Block
,
stop
<-
chan
struct
{})
(
uint64
,
[]
byte
,
[]
byte
)
Search
(
block
Block
,
stop
<-
chan
struct
{})
(
uint64
,
[]
byte
)
Verify
(
block
Block
)
bool
Verify
(
block
Block
)
bool
GetHashrate
()
int64
GetHashrate
()
int64
Turbo
(
bool
)
Turbo
(
bool
)
...
...
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